Bootstrap导航栏中的白色左右边距(White right and left margins in Bootstrap navbar)

这个问题一直困扰着我。 我正在使用Bootstrap框架,每当我在移动设备上查看我的网站时,我会在导航栏的右侧和左侧获得20px的边距。

过去有人建议如下:

.navbar-fixed-top { margin-left: -20px; margin-right: -20px; }

不幸的是,这不起作用。 它解决了导航栏边距的问题,但会在页面的其余部分产生问题。

您可以在此处查看此问题的示例: http : //www.theplaybook.co

任何见解都非常感谢。

This issue has been bothering me forever. I'm using the Bootstrap framework and whenever I view my site on mobile devices I get 20px margins on the right and left side of the navbar.

In the past some have suggested the following:

.navbar-fixed-top { margin-left: -20px; margin-right: -20px; }

Unfortunately, this doesn't work. It solves the issue with the navbar margins but creates issues with the rest of the page.

You can view an example of this problem here: http://www.theplaybook.co

Any insights are much appreciated.

最满意答案

它是由这一行引起的(在bootstrap-responsive.css ,802行):

@media (max-width: 767px) { .navbar { padding: 0 20px; }

It's caused by this line (in bootstrap-responsive.css, line 802):

@media (max-width: 767px) { .navbar { padding: 0 20px; }

更多推荐