gpt4 book ai didi

html - Bootstrap 菜单居中问题

转载 作者:太空宇宙 更新时间:2023-11-04 12:21:55 26 4
gpt4 key购买 nike

我试图将我的菜单居中,但我无法让它工作。当我更改浏览器/屏幕大小时,它的位置会中断。 (我知道尺寸太小会缩小) 菜单包含三个部分。左侧部分,搜索框和右侧部分。我希望我的菜单居中,但到目前为止还做不到。

这是我的代码。 http://jsfiddle.net/bhtf8f09/

图片:http://i.imgur.com/XBTlpq3.png

HTML

<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> &nbsp;<span class="glyphicon glyphicon-align-justify pull-right"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Account Settings <span class="glyphicon glyphicon-cog pull-right"></span></a></li>
<li class="divider"></li>
<li><a href="#">User stats <span class="glyphicon glyphicon-stats pull-right"></span></a></li>
<li class="divider"></li>
<li><a href="#">Messages <span class="badge pull-right"></span></a></li>
<li class="divider"></li>
<li><a href="#">Favourites Snippets <span class="glyphicon glyphicon-heart pull-right"></span></a></li>
<li class="divider"></li>
<li><a href="#">Sign Out <span class="glyphicon glyphicon-log-out pull-right"></span></a></li>
</ul>
</li>
<!--<li><a href="#"><span class="glyphicon glyphicon-align-justify"></span></a></li>-->
<li><a href="#"><span class="glyphicon glyphicon-home"></span> Anasayfa</a></li>
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Profil</a></li>
<!--<li><a href="#"><span class="glyphicon glyphicon-user"></span> Keşfet</a></li>-->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Keşfet &nbsp;<span class="glyphicon glyphicon-chevron-down pull-right"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Account Settings <span class="glyphicon glyphicon-cog pull-right"></span></a></li>
<li class="divider"></li>
<li><a href="#">User stats <span class="glyphicon glyphicon-stats pull-right"></span></a></li>
<li class="divider"></li>
<li><a href="#">Messages <span class="badge pull-right"></span></a></li>
<li class="divider"></li>
<li><a href="#">Favourites Snippets <span class="glyphicon glyphicon-heart pull-right"></span></a></li>
<li class="divider"></li>
<li><a href="#">Sign Out <span class="glyphicon glyphicon-log-out pull-right"></span></a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3 pull-left">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Arama" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
<ul class="nav navbar-nav">
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</div>
</nav>

CSS

html {
width:100%;
height:100%;
}

.collapse, .navbar-collapse {
width:55% !important;
margin:0 auto !important;
}

.navbar {
border-radius:0;
background-color:#bf5b5b;
}

.navbar-inverse .navbar-nav > li > a {
color:#fadaaf;
}

.navbar a {
color:#337ab7;
}


.glyphicon-chevron-down {
margin-top:3%;
}

最佳答案

你需要使用 .col-md-*.col-sm-* 可能还有要素。此标记可以大大简化并改进以更多地使用 Bootstrap 。尝试创建将所有内容放入应用居中边距的 .container 中。

关于html - Bootstrap 菜单居中问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28307381/

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