gpt4 book ai didi

html - Bootstrap 导航栏正在扩展到下一个容器

转载 作者:行者123 更新时间:2023-11-28 03:41:28 24 4
gpt4 key购买 nike

我的问题是我放在导航栏下的所有内容最终都进入了导航栏容器。我确定这是基本的东西(比如被遗忘的 div),但我无法发现它。我的代码有什么问题?这是代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Second Website</title>
<link href="style.css" rel="stylesheet">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">

</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>

<body>

<!-- Navigation -->

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand Name</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#"><span class="glyphicon glyphicon-home"></span>Home</a>
</li>
<li>
<a href="#"><span class="fa fa-database"></span>Products</a>
</li>
<li>
<a href="#"><span class="fa fa-book"></span>Contact</a>
</li>
<li class="slide"><a href="#" class="btn-slide1"><span class="fa fa-pencil"></span>Register</a></li>
<li class="slide"><a href="#" class="btn-slide2"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</div>
</nav>


<div class="container">

<div class="row">

<div class="col-md-10 col-md-offset-1">

<!-- About us title and description-->

<h2>About us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent rhoncus ultricies nibh, vitae sodales purus. Aenean volutpat ullamcorper cursus. Duis tristique sit amet augue ac vestibulum.</p>



</div>

</div>


</div>

</div>


</div>
</div>
</body>
</html>

还有 CSS:

body {
font-family: 'Raleway', sans-serif;
}

/* =========== NAVIGATION ============ */
.navbar {
min-height: 32px !important;
}
.navbar .navbar-brand{
padding: 0 12px;
font-size: 16px;
line-height: 38px;
height: 38px;
}
.navbar .navbar-nav > li > a {
padding-top: 0px;
padding-bottom: 0px;
line-height: 38px;
}
.navbar .navbar-toggle {
margin-top: 3px;
margin-bottom: 0px;
padding: 8px 9px;
}
.navbar .navbar-collapse {
border-color: #2f2f2f;
}

最佳答案

使用下面的 css class 并添加到 container

.marginTop {
margin-top:50px;
}

这是工作 fiddle

update code

body {
font-family: 'Raleway', sans-serif;
}

/* =========== NAVIGATION ============ */
.navbar {
min-height: 32px !important;
}
.navbar .navbar-brand{
padding: 0 12px;
font-size: 16px;
line-height: 38px;
height: 38px;
}
.navbar .navbar-nav > li > a {
padding-top: 0px;
padding-bottom: 0px;
line-height: 38px;
}
.navbar .navbar-toggle {
margin-top: 3px;
margin-bottom: 0px;
padding: 8px 9px;
}
.navbar .navbar-collapse {
border-color: #2f2f2f;
}

.marginTop {
margin-top:50px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Second Website</title>
<link href="style.css" rel="stylesheet">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">

</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>

<body>

<!-- Navigation -->

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand Name</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#"><span class="glyphicon glyphicon-home"></span>Home</a>
</li>
<li>
<a href="#"><span class="fa fa-database"></span>Products</a>
</li>
<li>
<a href="#"><span class="fa fa-book"></span>Contact</a>
</li>
<li class="slide"><a href="#" class="btn-slide1"><span class="fa fa-pencil"></span>Register</a></li>
<li class="slide"><a href="#" class="btn-slide2"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</div>
</nav>


<div class="container marginTop">

<div class="row">

<div class="col-md-10 col-md-offset-1">

<!-- About us title and description-->

<h2>About us</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent rhoncus ultricies nibh, vitae sodales purus. Aenean volutpat ullamcorper cursus. Duis tristique sit amet augue ac vestibulum.</p>



</div>

</div>


</div>

</div>


</div>
</div>
</body>
</html>

关于html - Bootstrap 导航栏正在扩展到下一个容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44196644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com