Reputation: 8413
I wanted to ask – if I have 3 columns of DIVs that I want to responsively change to 2 and 1 depending on the width of the user's screen (1 column for mobile devices) – what's the best way to do it? The div
elements should simply stack under each other.
<div class="container">
<div class="row">
<!--left-->
<div class="col1">
</div>
<!--/left-->
<!--center-->
<div class="col2">
</div>
<!--/center-->
<!--right-->
<div class="col3">
</div>
<!--/right-->
</div>
</div>
<!-- /.container -->
Thank you!
PS My design looks like this:
To
Upvotes: 2
Views: 246
Reputation: 12923
you can accomplish this with the float
property. You'll just need to clear the floats by adding overflow:hidden
to the parent or using a clearfix:
CSS
.row{
overflow: hidden;
}
.col{
background: red;
width: 200px;
height: 200px;
float: left;
margin: 5px;
}
You can use display: inline-block;
to do the same
.col{
background: red;
width: 200px;
height: 200px;
display: inline-block;
margin: 5px 2px;
}
Upvotes: 5