How to set container width to 980px in bootstrap 3.0.2?

十年热恋 提交于 2019-12-13 04:50:07

问题


In bootstrap 3.0 I can wrap .container class with my class and set the width to my class to 980px

EX

             <div class="maincontainer">
                   <div class="container">
                       //some content
                   </div>
             </div>

CSS

         .maincontainer {
             max-width: 980px;
             margin:0 auto;
         }

That code will wrap my contents with 980px, but in bootstrap 3.0.2 the author has change class .container to width not max-width in bootstrap 3.0.

So it is hard to set 980px for my layout!! I'm using LESS css!

Any ideas?


回答1:


A few of choices

In bootstrap, if one is using responsive design on the grid, then width is set by a variable (currently in 3.0.2 on line 43 of grid.less and following, depending on size).

Choice #1

Change the @container-XX variable(s) controlling the width in the variables.less file to achieve the 980px (for whatever size(s) you want it) which will then make the .container control the width and be what you want. I recommend this only if you actually still want some form of responsive site.

Choice #2

If you want to control the width still by your .maincontainer class, then in the same variable file noted in #1, change all the @container-XX (for sm, md, lg) to be auto which will make elements fit to the wrapping container .maincontainer.

Choice #3

If you do not want a responsive site at all, but a statically set 980px then follow the directions in this SO answer.

My guess is you actually want #3, but I thought I would mention the other ideas as well.



来源:https://stackoverflow.com/questions/20011462/how-to-set-container-width-to-980px-in-bootstrap-3-0-2

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