How to choose the container 960px wide and not to 1200px in Bootstrap

怎甘沉沦 提交于 2019-12-04 05:20:20

Do you just want a fixed width website? If so then then just don't include bootstrap-responsive.css. The default width for a fixed width container will be 960px.

Otherwise if you still want the responsive features but no 1200px container you will need to customize your bootstrap install. To do that:

Bootstrap sets container width to 1170px on screens wider than 1200px.
For screens from 992px to 1200px width of container is set to 970px. You can read more about bootstrap's grid here
Now if you want to set container to 760px for large screens, you have to locate this and edit in bootstrap.css or add this code to your custom css:

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

and

@media (min-width: 992px) {
  .container {
    width: 960px;
   }
 }

Hope this helps

This works for me.

!important is not recommended to use. but you can try.

.container, .container-fluid{
 width: 960px !important;
}

For Bootstrap3, you can customize it to get 960px by default (http://getbootstrap.com/customize/)

  1. change @container-lg from ((1140px + @grid-gutter-width)) to ((940px + @grid-gutter-width)).
  2. change @grid-gutter-width from 30px to 20px.

then download your custom version of bootstrap and use it. It should be 960px by default now.

If you are using sass and bootstrap v3.3.1, just define these variable before importing bootstrap:

$grid-gutter-width: 20px;
$container-large-desktop: 940px + $grid-gutter-width;

For more info please check the variables source file: https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_variables.scss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!