Olex Ponomarenko ~ olex.co ~ @tholex
How to parse the tips and tricks
spanning 25 years of CSS features? 🤷♀️
When struggling with the options of flexbox, it's easy to say "this is impossible and too complex"
and not appreciate the long road to acquire them
We live in a golden age of layout design 🍕
Dates based on browser support / developer sanity
Dates based on browser support / developer sanity
* Slides in this deck
* IMO "Deprecated"
* Not in this deck
<center>
<table>
<tbody>
<tr>
<td class="item"><img src="first.png"></td>
<td class="item"><img src="second.png"></td>
<td class="item"><img src="third.png"></td>
</tr>
</tbody>
</table>
</center>
table {
border-collapse: collapse; /* Circa 2001 */
}
Purple box has inline content that floats around floated content that precedes it.
Width restrictions or
clear: right;
places the second orange image onto a new row
clear: right;
<div class="container">
<div class="item"><img src="first.png"></div>
<div class="item"><img src="second.png"></div>
<div class="item"><img src="third.png"></div>
<div class="clearfix" />
</div>
.item {
float: left;
width: 33.333333%;
}
.clearfix {
clear: both;
}
/*
.container:after {
content: '';
display: block;
clear: both;
}
*/
<div class="container">
<div class="item"><img src="first.png"></div>
<div class="item"><img src="second.png"></div>
<div class="item"><img src="third.png"></div>
<div class="clearfix" />
</div>
.item {
float: left;
width: 33.333333%;
}
.clearfix {
clear: both;
}
$('.container').masonry({
itemSelector: '.item',
columnWidth: 200
});
Text
.item {
display: inline-block;
vertical-align: top;
width: 33.333333%;
}
.container {
word-spacing: -0.3em;
/* or spacing hack of your choice */
}
<div class="container">
<div class="item"><img src="first.png"></div>
<div class="item"><img src="second.png"></div>
<div class="item"><img src="third.png"></div>
</div>
Wait what was that -0.3em?
.container {
font-size: 0;
/* REM or PX Styleguide-dependent! */
}
.container {
word-spacing: -0.28em; /* FONT! dependent */
}
<div>...</div><div>...</div>
<!-- no space - no problem! -->
.container {
display: flex;
flex-wrap: wrap;
}
.item {
width: 33.333333%;
/* or flex: 1 0; */
}
<div class="container">
<div class="item"><img src="first.png"></div>
<div class="item"><img src="second.png"></div>
<div class="item"><img src="third.png"></div>
</div>
.container {
grid-template-columns: 33.33333% 33.33333% 33.33333%;
}
.item {}
p {
columns: 12em auto;
}
<p>Lorem ipsum...</p>
https://www.w3schools.com/tags/att_div_align.asp
<img align="left" src="first.png">
<img align="right" src="third.png">
<table width="200" align="left">
<tbody>
<tr>
<td class="item"><img src="first.png"></td>
</tr>
</tbody>
</table>
<table width="200" align="right">
<tbody>
<tr>
<td class="item"><img src="third.png"></td>
</tr>
</tbody>
</table>
<img align="left" src="first.png">
<img align="right" src="second.png">
<table width="200" align="left">
<tbody>
<tr>
<td class="item"><img src="first.png"></td>
</tr>
</tbody>
</table>
<table width="200" align="right">
<tbody>
<tr>
<td class="item"><img src="second.png"></td>
</tr>
</tbody>
</table>
Dates based on browser support / developer sanity
Dates based on browser support / developer sanity
* The modes I'd recommend knowing the best
and second best
(also display: block)
(+ the other 6-7 good ways to put things side by side)
P.S. Firefox Dev Tools > Chrome