如何更改navbar /容器宽度?引导3 [英] How to change navbar/container width? Bootstrap 3

查看:135
本文介绍了如何更改navbar /容器宽度?引导3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的导航栏的默认宽度太宽, 1170px 。我想把它减少到 940px - 但我想保持响应。

The default width for my navbar is too wide 1170px. I would like to reduce it down to 940px - but I want to keep the responsiveness.

我试图改变CSS中的容器宽度,并且使用大型浏览器看起来确定,但是当查看移动设备尺寸时,页面的其余部分会分开。

I tried to change the container width in CSS and it looks ok with a large browser, but the rest of the page falls apart when viewing for mobile sizes.

这是正确的属性还是还有别的什么?

Is this the correct property or is there something else?

@media (min-width: 1200px) {
  .container {
  max-width: 1170px;
}

这是我的navbar代码

Here is my navbar code

<div class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>

          </button>
          <a class="navbar-brand" href="#">Site Name</a>
        </div>

        <div class="collapse navbar-collapse">

          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="#shop">Shop</a></li>
            <li><a href="#showcase">Showcase</a></li>
            <li><a href="#help">Help</a></li>
            <li><a href="#my account">My Account</a></li>
            <li><a href="#cart">Cart <span class="glyphicon glyphicon-shopping-cart"></span></a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
  </div>


推荐答案

您在正确的轨道上。

@media (min-width: 1200px) {
    .container{
        max-width: 970px;
    }
}

这里我们说:在viewports 1200px或更大container max-width to 970px。这将覆盖当前将该范围的最大宽度设置为1170像素的标准类。

Here we say: On viewports 1200px or larger - set container max-width to 970px. This will overwrite the standard class that currently sets max-width to 1170px for that range.

注意:确保在bootstrap.css文件这个小错误在过去)。

NOTE: Make sure you include this AFTER the bootstrap.css stuff (everyone has made this little mistake in the past).

希望这有助于..好运!

Hope this helps.. good luck!

这篇关于如何更改navbar /容器宽度?引导3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆