Different behaviours for col-lg

2019-03-06 18:07发布

I have a card that uses size 3 for col-lg. But I want a different behaviour for monitors 1920x1080 and 1366x768. But both are still col-lg.

For example:

  • col-1g-2920x1080 = col-IgG
  • col-1g-1366x768 = col-IgG

<div class="catalogo">
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
</div>
</div>
</div>

2条回答
Viruses.
2楼-- · 2019-03-06 18:47

You can do same as you were doing earlier but need to download the bootstrap 4 sass file and reset lg grid breakpoint from _variables.scss file to 1080px like this

$grid-breakpoints: (
  xs: 0,
  sm: 576px,
  md: 768px,
  lg: 1080px,
  xl: 1200px
) !default;

and recompile the entire source to get new custom bootstrap CSS file. and use it like this.

<div class="catalogo">       
 <div class="row">         
  <div class="col-12 col-md-6 col-lg-3 "> </div>
 </div>
</div>

This is the file you need to change. https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss

But as a developer this is not recommended. But of course, it is possible if you deliberately want to achieve such kind of design.

Bootstrap 3 uses less preprocessor I believe it's variable.less contain @screen-sm: 768px; @screen-md: 992px;@screen-lg: 1200px; no xl so you can edit according to your need and recompile it. I think this should work.

查看更多
Anthone
3楼-- · 2019-03-06 19:10

You can use CSS media queries to differentiate between the two screen sizes:

E.g.:

.col-lg-3 {
    /* styles for 1366x768px screen */
}
@media screen and (min-width: 1920px) and (min-height: 1080px) {
    .col-lg-3 {
        /* styles for screens larger than or equal to 1920px by 1080px */
    }
}
查看更多
登录 后发表回答