gpt4 book ai didi

html - 如何更改导航栏位置? CSS & HTML

转载 作者:行者123 更新时间:2023-11-28 16:30:46 25 4
gpt4 key购买 nike

我希望我能在这里向你们解释我所需要的一切:)

我想要这样的: http://i.imgur.com/OzyQlHC.png

但在我的代码中,我尝试了一些东西,但我无法达到目的 :S 我不知道该怎么做,我也没有找到我想要的东西......

这是我的代码:

<body>


<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1">
<span class="sr-only">Desplegar navegación</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-center navbar-brand" href="#"><a class="navbar-brand">JVasconcelos</a></div>



<div class="collapse navbar-collapse" id="navbar-collapse-1">

<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input class="form-control" placeholder="Search" type="text">
</div>
<button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
</form>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">CV</a></li>
<li><a href="#">Contacto</a></li>
</ul>
</div> <!-- /.navbar-collapse -->
</nav>

<footer>

<h3> &copy; 2016 - Jose Antonio - JVasconcelos </h3>

</footer>

<script src="js/jquery-2.2.4.min.js"></script>
<script src="js/bootstrap.min.js"></script>

</body>

这是 CSS:

.navbar-brand { float: none; }
.navbar-center { position: absolute; width: 100%; text-align: center; margin: auto; height:100%; }

--> 编辑:我是用这段代码做的,但如果存在另一种更简单的方法呢?

.navbar { margin-top: 90px; margin-left: 450px; width: 900px; }

非常感谢您观看这篇文章并在可能的情况下提供帮助:)

最佳答案

您不必使用任何技巧。

只需将您的代码放在 div 中,类为 container。将顶部和底部边距设置为 body 即可。

HTML:

<div class="container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" 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 class="navbar-brand" href="#">Brand</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">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="content">Content</div>
<footer>Footer</footer>
</div>

CSS:

body {
margin-top: 100px;
margin-bottom: 100px;
}
.navbar {
margin-bottom: 0;
}
.content,
footer{
height: 1000px;
background: #333;
color: #fff;
font-size: 60px;
text-align: center;
padding-top: 400px
}
footer {
height: 100px;
background: #eee;
color: #333;
padding: 0;
}

CODEPEN EXAMPLE

关于html - 如何更改导航栏位置? CSS & HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37623720/

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