我剛剛發(fā)現(xiàn)了這個小問題,但解決方案卻從我的指縫中溜走了。我有一個包含多個折疊部分的頁面,我想在您單擊右側按鈕時顯示該頁面?,F(xiàn)在,一切都按照 Bootstrap 和 Js 庫完美運行,但我注意到,當你的屏幕不夠大時,你看不到 div 展開/顯示。下面是來自 w3c 學校的簡單代碼,該代碼適用于此示例。<!DOCTYPE html><html><head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script></head><body><div class="container"> <h2>Collaps 1</h2> <p>Click on the button to toggle between showing and hiding content.</p> <button type="button" class="btn btn-primary" data-toggle="collapse" data-target="#demo1">Simple collapsible</button> <div id="demo1" class="collapse"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </div> <h2>Collaps 2</h2> <p>Click on the button to toggle between showing and hiding content.</p> <button type="button" class="btn btn-primary" data-toggle="collapse" data-target="#demo2">Simple collapsible</button> <div id="demo2" class="collapse"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </div> </div> </div></body></html>我還嘗試使用一些暗示scrollTop的js函數(shù),就像那樣$('html,body').animate({scrollTop: $('#demo3).offset().top -200}, 500);但沒有成功。
- 0 回答
- 0 關注
- 184 瀏覽
添加回答
舉報
0/150
提交
取消