Bootstrap 3 - Set Container Width to 940px Maximum for Desktops?

后端 未结 5 1861
情歌与酒
情歌与酒 2020-12-13 02:26

I am adding a whole new section to a website using Twitter Bootstrap 3, however the container cannot go wider than 940px in total for Desktop - as it will throw out the Head

5条回答
  •  甜味超标
    2020-12-13 03:14

    In the first place consider the Small grid, see: http://getbootstrap.com/css/#grid-options. A max container width of 750 px will maybe to small for you (also read: Why does Bootstrap 3 force the container width to certain sizes?)

    When using the Small grid use media queries to set the max-container width:

    @media (min-width: 768px) { .container { max-width: 750px; } }

    Second also read this question: Bootstrap 3 - 940px width grid?, possible duplicate?

    12 x 60 = 720px for the columns and 11 x 20 = 220px

    there will also a gutter of 20px on both sides of the grid so 220 + 720 + 40 makes 980px

    there is 'no' @ColumnWidth

    You colums width will be calculated dynamically based on your settings in variables.less. you could set @grid-columns and @grid-gutter-width. The width of a column will be set as a percentage via grid.less in mixins.less:

    .calc-grid(@index, @class, @type) when (@type = width) {
      .col-@{class}-@{index} {
        width: percentage((@index / @grid-columns));
      }
    }
    

    update Set @grid-gutter-width to 20px;, @container-desktop: 940px;, @container-large-desktop: @container-desktop and recompile bootstrap.

提交回复
热议问题