javascript - bootstrap導航欄莫名多出20px,怎么回事
問題描述
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <meta http-equiv='X-UA-Compatible' content='IE=edge'> <meta name='viewport' content='width=device-width, initial-scale=1'> <title>html</title> <link rel='stylesheet' href='http://www.lshqa.cn/wenda/rule/bootstrap-Normalize.css'> <link rel='stylesheet' > <script src='https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js' integrity='sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa' crossorigin='anonymous'></script></head><body> <nav class='navbar navbar-inverse navbar-fixed-top'><p class='container'> <!-- Brand and toggle get grouped for better mobile display --> <p class='navbar-header'><button type='button' data-toggle='collapase' data-target='#bs-example-navbar-collapse-1' aria-expanded='false'> <span class='sr-only'>Toggle navigation</span> <span class='icon-bar'></span> <span class='icon-bar'></span> <span class='icon-bar'></span></button><a href='http://www.lshqa.cn/wenda/4549.html#'>Brand</a> </p> <!-- Collect the nav links, forms, and other content for toggling --> <p ><ul class='nav navbar-nav'> <li class='active'><a href='http://www.lshqa.cn/wenda/4549.html#'>Link <span class='sr-only'></span></a>Link</li> <li class='dropdown'><a href='http://www.lshqa.cn/wenda/4549.html#' data-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false'>Dropdown <span class='caret'></span></a><ul class='dropdown-menu'> <li><a href='http://www.lshqa.cn/wenda/4549.html#'>Action</a></li> <li><a href='http://www.lshqa.cn/wenda/4549.html#'>Another action</a></li> <li><a href='http://www.lshqa.cn/wenda/4549.html#'>Something else here</a></li> <li><a role='separator' href='http://www.lshqa.cn/wenda/4549.html#'></a></li> <li><a href='http://www.lshqa.cn/wenda/4549.html#'>Separated link</a></li> <li><a role='separator' href='http://www.lshqa.cn/wenda/4549.html#'></a></li> <li><a href='http://www.lshqa.cn/wenda/4549.html#'>One more separated link</a></li></ul> </li></ul> </p></p> </nav> <!-- jQuery (necessary for Bootstrap’s JavaScript plugins) --> <script src='https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js'></script> <!-- Include all compiled plugins (below), or include inpidual files as needed --> <script src='https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js'></script> <script src='http://www.lshqa.cn/wenda/main.js'> </script></body></html>
問題解答
回答1:這是因為,Bootstrap的導航欄只是默認是51px高,而并非永遠是51px高,如果其中有元素出現多行,是會將高度撐高的。
你的demo里,由于有一個標簽多了一個Link,所以將整個導航欄撐高了20px。
是不是框架給的? marign:0 或者padding:0 有木有效
回答3:你可以在控制臺DOM樹上找到導航欄,然后一個一個的從里往外刪元素,排查到是哪個元素導致的
相關文章:
1. javascript - html引入外部js文件保存拒絕加載腳本是怎么回事?2. 哪位大神幫我看看這是怎么回事 ajax老是報錯3. html5 - 百度Ueditor代碼高亮和代碼段滾動條沖突是怎么回事?4. html5 - H5頁面嵌入原生app顯示錯了,怎么回事?5. angular.js - items.query is not a function這是怎么回事6. python打開.py文件的時候出現window無法打開該文件是怎么回事呢?7. 老師,按tab鍵不起作用怎么回事8. python - 使用django-guardian賦予的object-permission在admin后臺不生效,這是怎么回事?9. h-ui模板導入報錯,怎么回事呢,我是用的TP5.110. 我用了啟動那一行的代碼后,網頁上的視頻就沒有聲音了,怎么回事
