Laying out content on the web is one of the many challenges of responsive web development. Positioning content and ensuring consistent behaviour on smaller to larger screen devices requires hacks and workarounds that can be frustrating to wrestle with and when employed wrongly, can make code harder to maintain. Fortunately, the rise of responsive web development has also increased the number of tools that we can use in order to make our workflow easier. The new CSS Grid specification is one of such examples that gives us the power to control grid structures through CSS instead of HTML making laying out content to be easier. In this talk, I will walk you through the future of laying out content on the web.
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Layouts in the world of mobile devices aysha anggraini
1. Layouts in the World of
Mobile Devices
Rakuten Tech Conference 2017
Aysha Anggraini
Rakuten Viki
2. 2
Layouts of the Past
● Floats
● Inline-blocks
● Table display
● Absolute & relative positionings
● Javascript
Previous Tools to Wrestle with Layouts
3. 3
How is it a problem?
Previous tools are not meant to be used for layouts
Layouts of the Past
Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. Vestibulum tortor quam,
feugiat vitae, ultricies eget, tempor sit amet, ante.
A common use case for floats
Name Age
Cersei Lannister 35
Tables - often abused for equal height columns
4. 4
Working with hacks has consequences
Previous Tools are Hacks
Layouts of the Past
● Heavily reliant on the source order of HTML
■ Row wrappers to pull & push margins
■ No good way to order elements <div class="row">
<div class="col s12 l8">
<div class="about"></div>
</div>
<div class="col s12 l4">
<div
class="episodes"></div>
</div>
</div>
About
Trailers
Trailers About
On mobile
On Desktop
5. 5
● Elements have no relationship with one another
■ Floats and equal height columns don’t work well
■ Items do not align as expected
● Complicated CSS and Markups
Column 1
Column 2
Column 3
Column 4
6. 6
Flexbox
Layout mode for working with elements arranged in one
dimension. This works best for equal height columns &
vertical centering of elements. It is not for working with
page layouts.
7. 7
Laying out elements in a single dimensions — rows or columns
Candidates for Flexbox
Layouts of the Present
11. 11
CSS Grid
Layout mode for working with elements arranged in two
dimension. A true layout system for laying content on
the web.
12. 12
Laying out elements in a two dimensions — rows and columns
The Magic of CSS Grid
Layouts of the Future
● Simpler to use
■ No more relying on markup’s source order
■ Maintainable code
21. 21
The FR Unit
CSS Grid
Layouts of the Future
.wrapper {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 10px;
}
FR units can be mixed!
25% 25% 1fr 1fr or
500px repeat(2, 1fr)