导航栏的定位

时间:2017-03-05 19:21:40

标签: html css twitter-bootstrap

我无法更改当前导航栏的位置。有谁知道该怎么做,它将被定位在徽标下方的中心位置?我已经包含了一张我希望导航栏看起来的图片。

How I would like the nav bar to be

declare @personid int;
declare @personname varchar(255);

if @peopleid not like '%[^0-9]%'
    set @personname = @peopleid;
else
    set @personid = convert(int, @peopleid);

where (personid = @personid or
       person.first_name + ' ' + person.last_name LIKE '%' + @personname + '%'
      )
.navbar.navbar-default {
  background-color: #ffffff;
  border-color: #ffffff;
  padding-top:15px;
  padding-bottom:30px;
}
.navbar.navbar-default .navbar-brand {
  color: #696969;
}
.navbar.navbar-default .navbar-brand:hover,
.navbar.navbar-default .navbar-brand:focus {
  color: #ff9c74;
}
.navbar.navbar-default .navbar-text {
  color: #292929;
}
.navbar.navbar-default .navbar-nav > li > a {
  color: #292929;
}
.navbar.navbar-default .navbar-nav > li > a:hover,
.navbar.navbar-default .navbar-nav > li > a:focus {
  color: #747474;
}
.navbar.navbar-default .navbar-nav > .active > a,
.navbar.navbar-default .navbar-nav > .active > a:hover,
.navbar.navbar-default .navbar-nav > .active > a:focus {
  color: #ff9c74;
  background-color: #ffffff;
}
.navbar.navbar-default .navbar-nav > .open > a,
.navbar.navbar-default .navbar-nav > .open > a:hover,
.navbar.navbar-default .navbar-nav > .open > a:focus {
  color: #ff9c74;
  background-color: #ffffff;
}
.navbar.navbar-default .navbar-toggle {
  border-color: #ffffff;
}
.navbar.navbar-default .navbar-toggle:hover,
.navbar.navbar-default .navbar-toggle:focus {
  background-color: #ffffff;
}
.navbar.navbar-default .navbar-toggle .icon-bar {
  background-color: #292929;
}
.navbar.navbar-default .navbar-collapse,
.navbar.navbar-default .navbar-form {
  border:none;
}
.navbar.navbar-default .navbar-link {
  color: #292929;
}
.navbar.navbar-default .navbar-link:hover {
  color: #696969;
}

.navbar-brand {
  transform: translateX(-50%);
  left: 50%;
  position: absolute;
}

.nav.navbar-nav > li.navbar-left {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 11.5px;
}

.navbar-brand {
  padding: 10px;
}

.navbar-brand>img {
  height: 50px;
  width: auto
}

@media (min-width: 768px) {
    .navbar-brand { display: block; }
    .navbar-bar-default .navbar-toggle {text-align: left;}
}

.fa.fa-instagram {
  font-size: 18px;
}
.fa.fa-pinterest {
  font-size: 18px;
}
.fa.fa-dribbble {
  font-size: 18px;
}
.fa.fa-twitter{
  font-size: 18px;
}

.banner {
  width: 100%;
}

.banner-inner {
  max-width:1100px;
  margin: 0 auto;
}

@media (min-width:468px) and (max-width:991px){
  .container.navbar-container {
     width:100%;
     padding:0px;
  }
}

@media (min-width:468px) and (max-width:991px){
  .container.navbar-container {
     width:100%;
     padding:0px;
  }
}


body { padding-top: 90px; }
@media screen (min-width: 468px) and (max-width: 768px) {
    body { padding-top: 0px; }
}

.banner-inner>img {
opacity:0;
-moz-transition: opacity 2s; /* Firefox 4 */
-webkit-transition: opacity 2s; /* Safari and Chrome */
-o-transition: opacity 2s;
transition: opacity 2s;
}

.col-1-1> img{
opacity:0;
-moz-transition: opacity 2s; /* Firefox 4 */
-webkit-transition: opacity 2s; /* Safari and Chrome */
-o-transition: opacity 2s;
transition: opacity 2s;

}

1 个答案:

答案 0 :(得分:0)

您当前的HTML无效,因此我修改了一些小东西。主要是将你的图像放在它自己的div中,给它一个“ margin-top:50px; ”,这样它就会在你的模拟显示时按下Nav。 (并且为了好玩而放入一个有趣的徽标= P.你可以用真实的替换它。)你遇到困难的原因是你还需要覆盖CSS boostrap默认代码w / your拥有徽标。

在桌面中它现在看起来像你的模拟。在Mobile中,仍然看起来很好用同一行中的Logo和汉堡菜单。 (你没有说明你想要移动的行为,所以我希望没问题。)

添加我已放入CodePen的代码:http://codepen.io/alejandra_quetzalli/pen/YZWMLY?editors=1100

img.navbar-brand {
    height: 45px;
    margin: 0;
    padding: 0;
}
.navbar.navbar-default {
  background-color: #ffffff;
  border-color: #ffffff;
  padding-top:15px;
  padding-bottom:30px;
}
.navbar.navbar-default .navbar-brand {
  color: #696969;
}
.navbar.navbar-default .navbar-brand:hover,
.navbar.navbar-default .navbar-brand:focus {
  color: #ff9c74;
}
.navbar.navbar-default .navbar-text {
  color: #292929;
}
.navbar.navbar-default .navbar-nav > li > a {
  color: #292929;
}
.navbar.navbar-default .navbar-nav > li > a:hover,
.navbar.navbar-default .navbar-nav > li > a:focus {
  color: #747474;
}
.navbar.navbar-default .navbar-nav > .active > a,
.navbar.navbar-default .navbar-nav > .active > a:hover,
.navbar.navbar-default .navbar-nav > .active > a:focus {
  color: #ff9c74;
  background-color: #ffffff;
}
.navbar.navbar-default .navbar-nav > .open > a,
.navbar.navbar-default .navbar-nav > .open > a:hover,
.navbar.navbar-default .navbar-nav > .open > a:focus {
  color: #ff9c74;
  background-color: #ffffff;
}
.navbar.navbar-default .navbar-toggle {
  border-color: #ffffff;
}
.navbar.navbar-default .navbar-toggle:hover,
.navbar.navbar-default .navbar-toggle:focus {
  background-color: #ffffff;
}
.navbar.navbar-default .navbar-toggle .icon-bar {
  background-color: #292929;
}
.navbar.navbar-default .navbar-collapse,
.navbar.navbar-default .navbar-form {
  border:none;
  margin-top: 50px;
}
.navbar.navbar-default .navbar-link {
  color: #292929;
}
.navbar.navbar-default .navbar-link:hover {
  color: #696969;
}

.navbar-brand {
  transform: translateX(-50%);
  left: 50%;
  position: absolute;
}

.nav.navbar-nav > li.navbar-left {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 11.5px;
}

.navbar-brand {
  padding: 10px;
}

.navbar-brand>img {
  height: 50px;
  width: auto
}

@media (min-width: 768px) {
    .navbar-brand { display: block; }
    .navbar-bar-default .navbar-toggle {text-align: left;}
}

.fa.fa-instagram {
  font-size: 18px;
}
.fa.fa-pinterest {
  font-size: 18px;
}
.fa.fa-dribbble {
  font-size: 18px;
}
.fa.fa-twitter{
  font-size: 18px;
}

.banner {
  width: 100%;
}

.banner-inner {
  max-width:1100px;
  margin: 0 auto;
}

@media (min-width:468px) and (max-width:991px){
  .container.navbar-container {
     width:100%;
     padding:0px;
  }
}

@media (min-width:468px) and (max-width:991px){
  .container.navbar-container {
     width:100%;
     padding:0px;
  }
}


body { padding-top: 90px; }
@media screen (min-width: 468px) and (max-width: 768px) {
    body { padding-top: 0px; }
}

.banner-inner>img {
opacity:0;
-moz-transition: opacity 2s; /* Firefox 4 */
-webkit-transition: opacity 2s; /* Safari and Chrome */
-o-transition: opacity 2s;
transition: opacity 2s;
}

.col-1-1> img{
opacity:0;
-moz-transition: opacity 2s; /* Firefox 4 */
-webkit-transition: opacity 2s; /* Safari and Chrome */
-o-transition: opacity 2s;
transition: opacity 2s;

}




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device=width, initial-scale=1.0">
      <title></title>
       <meta name="author" content="">
    <link rel="icon" type="image/png" href="img/icon.png"/>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link href="css/sticky-footer.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Nunito|Nunito+Sans|Playfair+Display" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    </head>
<body>
    <header>

          <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <div><img class="navbar-brand" href="http://" onload="this.style.opacity='1';" class= "logo" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/32877/logo-thing.png"></div>
        <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>

      </div>
<!--         <div><img class="navbar-brand" href="http://" onload="this.style.opacity='1';" class= "logo" src="img/logo.png"></div> -->
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav">
      <li class="navbar-left"><a href="http://www">TRAVEL</a></li>
          <li class="navbar-left"><a href="http://www"> PORTFOLIO </a></li>
      <li class="navbar-left"><a href="http://www"> INSPO </a></li>
          <li class="navbar-left"><a href="http://www"> ABOUT </a></li>
        </ul>
      <ul class="nav navbar-nav navbar-right">
          <li class="right"> <a href="https://www.instagram.com/"><i class="fa fa-instagram"></i></a></li>
      <li class="right"> <a href="https://dribbble.com/"><i class="fa fa-dribbble"></i></a></li>
      <li class="right"> <a href="https://www.pinterest.com/"><i class="fa fa-pinterest"></i></a></li>
      <li class="right"> <a href="https://twitter.com/"><i class="fa fa-twitter"></i></a></li> 
        </ul>
      </div>
      <!--/.nav-collapse -->
    </div>
    <!--/.container-fluid -->
  </div>
</div>
    </header>
<!---End Header-->
    <section class="banner">
        <div class="banner-inner">
            <img onload="this.style.opacity='1';" class="banner" src="img/background.jpg">
        </div>
    </section>
<!---End Banner-->
<!-- Begin page content -->
    <footer class="footer">
      <div class="container">
        <span class>Copyright &copy; 2017. JH. All rights reserved.</span>
      </div>
    </footer>
<!---End Footer-->
<!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>

修改

更新了上述代码,以便按要求将导航栏链接/图标居中。

<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device=width, initial-scale=1.0">
      <title></title>
       <meta name="author" content="">
    <link rel="icon" type="image/png" href="img/icon.png"/>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link href="css/sticky-footer.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Nunito|Nunito+Sans|Playfair+Display" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    </head>
<body>
    <header>

          <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <div><img class="navbar-brand" href="http://" onload="this.style.opacity='1';" class= "logo" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/32877/logo-thing.png"></div>
        <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>

      </div>
<!--         <div><img class="navbar-brand" href="http://" onload="this.style.opacity='1';" class= "logo" src="img/logo.png"></div> -->
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav">
      <li class="navbar-left"><a href="http://www">TRAVEL</a></li>
          <li class="navbar-left"><a href="http://www"> PORTFOLIO </a></li>
      <li class="navbar-left"><a href="http://www"> INSPO </a></li>
          <li class="navbar-left"><a href="http://www"> ABOUT </a></li>
        </ul>
      <ul class="nav navbar-nav">
          <li class="right"> <a href="https://www.instagram.com/"><i class="fa fa-instagram"></i></a></li>
      <li class="right"> <a href="https://dribbble.com/"><i class="fa fa-dribbble"></i></a></li>
      <li class="right"> <a href="https://www.pinterest.com/"><i class="fa fa-pinterest"></i></a></li>
      <li class="right"> <a href="https://twitter.com/"><i class="fa fa-twitter"></i></a></li> 
        </ul>
      </div>
      <!--/.nav-collapse -->
    </div>
    <!--/.container-fluid -->
  </div>
</div>
    </header>
<!---End Header-->
    <section class="banner">
        <div class="banner-inner">
            <img onload="this.style.opacity='1';" class="banner" src="img/background.jpg">
        </div>
    </section>
<!---End Banner-->
<!-- Begin page content -->
    <footer class="footer">
      <div class="container">
        <span class>Copyright &copy; 2017. JH. All rights reserved.</span>
      </div>
    </footer>
<!---End Footer-->
<!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>



<style>
img.navbar-brand {
    height: 45px;
    margin: 0;
    padding: 0;
}
.navbar.navbar-default {
  background-color: #ffffff;
  border-color: #ffffff;
  padding-top:15px;
  padding-bottom:30px;
}
.navbar.navbar-default .navbar-brand {
  color: #696969;
}
.navbar.navbar-default .navbar-brand:hover,
.navbar.navbar-default .navbar-brand:focus {
  color: #ff9c74;
}
.navbar.navbar-default .navbar-text {
  color: #292929;
}
.navbar.navbar-default .navbar-nav > li > a {
  color: #292929;
}
.navbar.navbar-default .navbar-nav > li > a:hover,
.navbar.navbar-default .navbar-nav > li > a:focus {
  color: #747474;
}
.navbar.navbar-default .navbar-nav > .active > a,
.navbar.navbar-default .navbar-nav > .active > a:hover,
.navbar.navbar-default .navbar-nav > .active > a:focus {
  color: #ff9c74;
  background-color: #ffffff;
}
.navbar.navbar-default .navbar-nav > .open > a,
.navbar.navbar-default .navbar-nav > .open > a:hover,
.navbar.navbar-default .navbar-nav > .open > a:focus {
  color: #ff9c74;
  background-color: #ffffff;
}
.navbar.navbar-default .navbar-toggle {
  border-color: #ffffff;
}
.navbar.navbar-default .navbar-toggle:hover,
.navbar.navbar-default .navbar-toggle:focus {
  background-color: #ffffff;
}
.navbar.navbar-default .navbar-toggle .icon-bar {
  background-color: #292929;
}
.navbar.navbar-default .navbar-collapse,
.navbar.navbar-default .navbar-form {
  border:none;
  margin-top: 50px;
}
#navbar {
    text-align: center;
}
ul.navbar-nav {
  display: inline-block;
}
.navbar.navbar-default .navbar-link {
  color: #292929;
}
.navbar.navbar-default .navbar-link:hover {
  color: #696969;
}

.navbar-brand {
  transform: translateX(-50%);
  left: 50%;
  position: absolute;
}

.nav.navbar-nav > li.navbar-left {
  font-family: 'Nunito Sans', sans-serif;
  font-size: 11.5px;
}

.navbar-brand {
  padding: 10px;
}

.navbar-brand>img {
  height: 50px;
  width: auto
}

@media (min-width: 768px) {
    .navbar-brand { display: block; }
    .navbar-bar-default .navbar-toggle {text-align: left;}
  ul.navbar-nav {
    float: none;
  }
}
ul.navbar-nav {
    float: none;
  }
.fa.fa-instagram {
  font-size: 18px;
}
.fa.fa-pinterest {
  font-size: 18px;
}
.fa.fa-dribbble {
  font-size: 18px;
}
.fa.fa-twitter{
  font-size: 18px;
}

.banner {
  width: 100%;
}

.banner-inner {
  max-width:1100px;
  margin: 0 auto;
}

@media (min-width:468px) and (max-width:991px){
  .container.navbar-container {
     width:100%;
     padding:0px;
  }
}

@media (min-width:468px) and (max-width:991px){
  .container.navbar-container {
     width:100%;
     padding:0px;
  }
}


body { padding-top: 90px; }
@media screen (min-width: 468px) and (max-width: 768px) {
    body { padding-top: 0px; }
}

.banner-inner>img {
opacity:0;
-moz-transition: opacity 2s; /* Firefox 4 */
-webkit-transition: opacity 2s; /* Safari and Chrome */
-o-transition: opacity 2s;
transition: opacity 2s;
}

.col-1-1> img{
opacity:0;
-moz-transition: opacity 2s; /* Firefox 4 */
-webkit-transition: opacity 2s; /* Safari and Chrome */
-o-transition: opacity 2s;
transition: opacity 2s;
}

</style>