I have three <div> elements:
<div class="foo">A</div>
<div class="foo">B</div>
<div class="foo">C</div>
I'd like to write some CSS to create the following effect as the screen size changes:

I know how to implement the following (undesired) behavior:

div.foo {
display: inline-block;
vertical-align: top;
width: 300px;
}
Is there a simple way (pref. without any Javascript library) to achieve my desired behavior that will work on major browsers (Chrome, Safari, Firefox, IE9+)?
I don't think this is possible without an extra wrapper div and a media query.
HTML:
<div class="box-wrap">
<div class="box">a</div>
<div class="box">b</div>
</div>
<div class="box">c</div>
CSS:
.box {
border: 1px solid #000;
float: left;
height: 300px;
width: 300px;
}
.box-wrap {
float: left;
width: 300px;
}
@media (min-width: 900px) {
.box-wrap {
width: auto;
}
}
Demo: http://codepen.io/sdsanders/pen/zLFJj
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With