我试图集中注意力:
<div style="text-align:center; margin-top:16px;" class="hidden-xs">
<div>Free Estimates</div>
<div>Licensed & Insured #C98354</div>
</div>
我希望它始终位于它下面的div之上。
<div class="collapse navbar-collapse" id="navbar-collapse-02">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#slider-wrapper">Home</a>
</li>
<li>
<a href="#services">Services</a>
</li>
<li>
<a href="#about">About Us</a>
</li>
<li>
<a href="#portfolio">Ideas</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
</ul>
</div>
不幸的是,我无法弄清楚如何让它正确地居于div之上。
参考的完整标题代码:
<header class="item header margin-top-0 padding-bottom-70" id="header1">
<div class="wrapper">
<div class="container">
<nav class="navbar navbar-default navbar-lg navbar-fixed-top" role="navigation">
<div class="container">
<div class="col-lg-1">
<div class="navbar-header">
<button class="navbar-toggle" data-target="#navbar-collapse-02" data-toggle="collapse" type="button">
<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 brand" href="#">
<img src="images/new-logo-small.png">
</a>
<div class="hidden-xs"> A+ Rating BBB</div>
</div>
</div>
<div class="col-lg-6">
<div style="padding-top:67px; padding-left:125px; text-align:center; font-size:16px" class="hidden-md hidden-sm hidden-xs">
<div>
<div>Some Address</div>
<span class="fa fa-envelope"></span><span> <a style="text-decoration:none; color:#333">email@email.com</a> | </span>
<span class="fa fa-phone"></span><span> (727) 876-5309</span>
</div>
</div>
</div>
<div class="col-lg-5">
<!-- I want this to stay centered above the div below it -->
<div style="text-align:center; margin-top:16px;" class="hidden-xs">
<div>Free Estimates</div>
<div>Licensed & Insured #C98354</div>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-02">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#slider-wrapper">Home</a>
</li>
<li>
<a href="#services">Services</a>
</li>
<li>
<a href="#about">About Us</a>
</li>
<li>
<a href="#portfolio">Ideas</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
</div>
</nav>
</div>
</div>
</header>
答案 0 :(得分:1)
<div class="container" style="width: 1000px">
<div style="text-align:center; margin-top:16px; display: block; margin: 0 auto;" class="hidden-xs">
<div>Free Estimates</div>
<div>Licensed & Insured #C98354</div>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-02">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#slider-wrapper">Home</a>
</li>
<li>
<a href="#services">Services</a>
</li>
<li>
<a href="#about">About Us</a>
</li>
<li>
<a href="#portfolio">Ideas</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
答案 1 :(得分:0)
我使用边距中的百分比来居中导航栏和navbarnav。我希望这对你有所帮助。
<div class="makenavbarcenter">
<div class="hidden-xs headertitle">
<div>Free Estimates</div>
<div>Licensed & Insured #C98354</div>
</div>
<nav class="navbar navbar-default navbarmain">
<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>
</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 makenavbarnavcenter">
<li class="headerlinks"><a href="#">Home</a>
</li>
<li class="headerlinks"><a href="#">Services</a>
</li>
<li class="headerlinks"><a href="#">About Us</a>
</li>
<li class="headerlinks"><a href="#">Ideas</a>
</li>
<li class="headerlinks"><a href="#">Contact</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</div>
<style type="text/css">
.makenavbarcenter {
margin-left: 20%;
margin-right: 20%;
}
.navbarmain {
background-color: transparent;
border-color: transparent;
}
.makenavbarnavcenter {
margin-right: 20%;
margin-left: 20%
}
.headertitle {
text-align: center;
margin-top: 16px;
}
.headerlinks {
padding: 0px;
margin: 0px;
}
</style>