I have three divs: a , b and c . They are 48% wide and displayed as inline blocks. This style will be applied to multiple pages. Div a will always be shorter than div b . This creates a gap between the bottom of a and the top of c . (Divs a and b will be slightly different in height on each page, but a will always be shorter. Due to inconsistent heights, I don’t feel like I can reliably use margin-top: -10px, for example.)
Like this:

How i want:

change
Mobile phone:

/ Change
CSS
div {
width:48%;
box-sizing:border-box;
display:inline-block;
border:1px solid;
vertical-align:top;
}
@media only screen and (max-width: 600px) {
div {
width:100%;
}
}
HTML
<div style="border-color:red;">a<br>a</div>
<div style="border-color:green;">b<br>b<br>b<br>b<br>b<br>b<br>b<br>b</div>
<div style="border-color:blue;">c<br>c<br>c<br></div>
A media query allows three divs to fit into a single column with smaller screen sizes. This is why the div should be in that order.
source
share