How to make divs stack without spaces and retain order on smaller sizes - in Bootstrap

后端 未结 7 1056
不思量自难忘°
不思量自难忘° 2021-01-18 02:47

I really don\'t know how to put this in words.

When I have 2 divs in a row, each has different height, so the next row have unwanted space.

But stack correct

7条回答
  •  太阳男子
    2021-01-18 03:17

    We can achieve it through @media queries

    And you need to add alternate float left right for divs

    HTML:

        
    div 1
    div 2
    div 3
    div 4
    div 5

    CSS:

    .wid{
    width:50%;
    }
    
    @media screen and (max-width:768px){
    .wid{
    width:100%;
    }
    }
    

提交回复
热议问题