twitter-bootstrap 导航栏固定顶部 Bootstrap 下方的空间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22888284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 20:26:28  来源:igfitidea点击:

Space below navbar-fixed-top Bootstrap

htmlcsstwitter-bootstrap

提问by Elton

There is a mysterious space (roughly 25px) between the navbar and the content div. I am using Chrome and 1600x900 screen resolution. I have looked at other questions with the exact same problem, and I applied the answers given, but the problem persists. I have set the margin bottom of the navbar to 0 and override Bootstrap 3.1.1. HTML

导航栏和内容 div 之间有一个神秘的空间(大约 25px)。我正在使用 Chrome 和 1600x900 屏幕分辨率。我查看了具有完全相同问题的其他问题,并应用了给出的答案,但问题仍然存在。我已将导航栏的底部边距设置为 0 并覆盖 Bootstrap 3.1.1。 HTML

<!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
            <title>Title</title>
            <meta name="description" content="">
            <meta name="viewport" content="width=device-width, initial-scale=1">

            <link rel="stylesheet" href="css/bootstrap.min.css">
            <link rel="stylesheet" href="css/hover.css">
            <link rel="stylesheet" href="css/style.css">
            <script src="js/lib/modernizr-2.6.2-respond-1.1.0.min.js"></script>
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>   
        </head>

        <body>
                <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
                    <div class="container-fluid">
                        <div class="navbar-header">
                            <a href="#"><img src="img/title.png"></img></a>
                        </div>
                        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                            <ul class="nav navbar-nav navbar-right">
                                <li><a href="#">Home</a></li>
                                <li><a href="#">About</a></li>
                                <li><a href="#">Contact</a></li>
                            </ul>     
                        </div><!-- /.navbar-collapse -->
                    </div><!-- /.container-fluid -->
                </nav>
                <div class="content"></div>           
        </body>

    </html>

CSS

CSS

body { 
  padding: 70px 0 0 0;
}
html, body{
  height: 100%;
}
/* Top Navigation Bar */
.navbar-fixed-top {
  background: #F7F7F7;
  min-height: 0;
  height: 45px;
  padding: 5px 0;
  margin-bottom: 0;
}
.navbar-header{
  height: 35px;
  padding: 5px 0;
}
.content{
  width: 100%;
  height: 450px;
  background: rgb(255, 240, 240);
}

回答by Zim

Change the body padding to..

将身体填充更改为..

body { 
  padding: 45px 0 0 0;
}

http://www.bootply.com/127737

http://www.bootply.com/127737