Bootstrap 3 - 940px width grid?

前端 未结 3 1590
心在旅途
心在旅途 2021-01-06 11:59

I am using Bootstrap 3 on a new project. The layout is to be a 940px max width (desktop etc), 12 col (60px column, 20px gutter).

I\'ve set .container to

相关标签:
3条回答
  • 2021-01-06 12:32

    The best option is to use the original LESS version of bootstrap (get it from github).

    Open variables.less and look for // Media queries breakpoints

    // Large screen / wide desktop
    @screen-lg:                  1200px; // change this
    @screen-lg-desktop:          @screen-lg;
    

    Change the last breakpoint to 9999px for example, and this will prevent this breakpoint to be reached, so your site always load the previous media query:

    @screen-md:                  992px; // this one has 940px container
    @screen-desktop:             @screen-md;
    

    To change the column width and gutter, scroll a little bit down in the same file and look for

    // Grid system
    // --------------------------------------------------
    
    // Number of columns in the grid system
    @grid-columns:              12;
    // Padding, to be divided by two and applied to the left and right of all columns
    @grid-gutter-width:         30px;
    // Point at which the navbar stops collapsing
    @grid-float-breakpoint:     @screen-tablet; 
    

    Here you can configure it

    And finally, ofcource compile bootstrap.less file in css.

    Cheers

    0 讨论(0)
  • 2021-01-06 12:45

    You must comment the following section in bootstrap.responsive.css for start 940 view

    @media (min-width: 1200px) {
    }
    
    0 讨论(0)
  • 2021-01-06 12:47

    Use:

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

    Note: 970 minus 30px (gutter) makes 940px for your design.

    update

    See: http://bootply.com/86257

    Set @grid-gutter-width to 20px; and recompile bootstrap.

    In this case your .container /.row will have a width of 960px. Defined in variabless.less: @container-desktop: ((940px + @grid-gutter-width));

    Note if setting @container-large-desktop: @container-desktop in variables.less i don't need the media query above.

    0 讨论(0)
提交回复
热议问题