Bootstrap 3 breakpoints and media queries

后端 未结 9 1337
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 09:08

On the Bootstrap 3 media queries documentation it says:

We use the following media queries in our Less files to create the key breakpoints in our grid

相关标签:
9条回答
  • 2020-11-27 09:44
    @media screen and (max-width: 767px) {
    
    }
    
    @media screen and (min-width: 768px) and (max-width: 991px){
    
    
    }
    
    @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape){
    
    
    }
    
    @media screen and (min-width: 992px) {
    
    
    
    }
    
    0 讨论(0)
  • 2020-11-27 09:46

    You should be able to use those breakpoints if you use http://lesscss.org/ to build your CSS.

    /* Extra small devices (phones, less than 768px) */
    /* No media query since this is the default in Bootstrap */
    
    /* Small devices (tablets, 768px and up) */
    @media (min-width: @screen-sm-min) {  }
    
    /* Medium devices (desktops, 992px and up) */
    @media (min-width: @screen-md-min) {  }
    
    /* Large devices (large desktops, 1200px and up) */
    @media (min-width: @screen-lg-min) {  }
    

    From https://getbootstrap.com/docs/3.4/css/#grid-media-queries

    In fact @screen-sm-min is a variable than is replaced by the value specified in _variable when building with Less. If you don't use Less, you can replace this variable by the value:

    /* Extra small devices (phones, less than 768px) */
    /* No media query since this is the default in Bootstrap */
    
    /* Small devices (tablets, 768px and up) */
    @media (min-width: 768px) {  }
    
    /* Medium devices (desktops, 992px and up) */
    @media (min-width: 992px) {  }
    
    /* Large devices (large desktops, 1200px and up) */
    @media (min-width: 1200px) {  }
    

    Bootstrap 3 officially supports Sass: https://github.com/twbs/bootstrap-sass. If you are using Sass (and you should) the syntax is a bit different.

    /* Extra small devices (phones, less than 768px) */
    /* No media query since this is the default in Bootstrap */
    
    /* Small devices (tablets, 768px and up) */
    @media (min-width: $screen-sm-min) { }
    
    /* Medium devices (desktops, 992px and up) */
    @media (min-width: $screen-md-min) {  }
    
    /* Large devices (large desktops, 1200px and up) */
    @media (min-width: $screen-lg-min) {  }
    
    0 讨论(0)
  • 2020-11-27 09:50

    Here are the selectors used in Bootstrap 4. There is no "lowest" setting in BS4 because "extra small" is the default. I.e. you would first code the XS size and then have these media overrides afterwards.

    @media(min-width:576px){}
    @media(min-width:768px){}
    @media(min-width:992px){}
    @media(min-width:1200px){}
    
    0 讨论(0)
提交回复
热议问题