How to set a fixed width column with CSS flexbox

后端 未结 2 1652
春和景丽
春和景丽 2020-12-12 10:33

CodePen: http://codepen.io/anon/pen/RPNpaP.

I want the red box to be only 25 em wide when it\'s in the side-by-side view - I\'m trying to achieve this by setting the

2条回答
  •  攒了一身酷
    2020-12-12 11:12

    In case anyone wants to have a responsive flexbox with percentages (%) it is much easier for media queries.

    flex-basis: 25%;
    

    This will be a lot smoother when testing.

    // VARIABLES
    $screen-xs:                                         480px;
    $screen-sm:                                         768px;
    $screen-md:                                         992px;
    $screen-lg:                                         1200px;
    $screen-xl:                                         1400px;
    $screen-xxl:                                        1600px;
    
    // QUERIES
    @media screen (max-width: $screen-lg) {
        flex-basis: 25%;
    }
    
    @media screen (max-width: $screen-md) {
        flex-basis: 33.33%;
    }
    

提交回复
热议问题