【问题标题】:Twitter Bootstrap centering responsive navbarTwitter Bootstrap 居中响应式导航栏
【发布时间】:2013-03-08 10:05:24
【问题描述】:

我正在尝试在 Twitter Bootstrap 中创建一个网站,但在使用响应式设计时我遇到了导航链接居中的问题。

基本上,对于平板电脑和手机设备,我想要一个两行导航栏,因此顶部是品牌名称,下方是导航链接。

我可以让品牌名称在屏幕上居中,但当我尝试将相同的样式应用到导航链接时,它会卡在左侧。

这里是演示这个问题的小提琴: http://jsfiddle.net/AsGHB/5/

这里是相关的 CSS:

@media (max-width: 767px) { 

 #bn-logo {
  width: 100%;
  float: none;
  margin: 0 auto;
  text-align: center;
  }

 .navbar .nav {
   width: 100%;
   float: none;
   margin: 0 auto;
   text-align: center;
  }
}

【问题讨论】:

    标签: html css twitter-bootstrap


    【解决方案1】:

    添加以下代码:

    @media (max-width: 767px)and (min-width: 480px) { 
      header{
        text-align:center;
      }
      .navbar .nav {
        float:none;
      }
      .navbar .nav > li {
        float: none;
        display: inline-block;
      }
    }
    

    【讨论】:

    • 有效!谢谢!这是使它居中的最后一部分: .navbar .nav > li { float: none;显示:内联块; }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2012-04-28
    • 1970-01-01
    • 2016-04-13
    • 2017-01-15
    相关资源
    最近更新 更多