SlideShare una empresa de Scribd logo
1 de 38
Descargar para leer sin conexión
Layouts in the World of
Mobile Devices
Rakuten Tech Conference 2017
Aysha Anggraini
Rakuten Viki
2
Layouts of the Past
● Floats
● Inline-blocks
● Table display
● Absolute & relative positionings
● Javascript
Previous Tools to Wrestle with Layouts
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
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
● 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
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
Laying out elements in a single dimensions — rows or columns
Candidates for Flexbox
Layouts of the Present
8
Centering elements
Candidates for Flexbox
Layouts of the Present
Column 1
9
Ordering Elements
Candidates for Flexbox
Layouts of the Present
Column 2 Column 4Column 3 Column 1
Can be done through order properties
10
Flexbox is not enough
11
CSS Grid
Layout mode for working with elements arranged in two
dimension. A true layout system for laying content on
the web.
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
13
<div class="row">
<div class="col s12 l8">
<div class="about"></div>
</div>
<div class="col s12 l4">
<div class="episodes"></div>
</div>
</div>
VS.
<div class="wrapper">
<div class="about"></div>
<div class="episodes"></div>
</div>
Floats CSS Grid
14
<div class="wrapper">
<div class="about"></div>
<div class="episodes"></div>
</div>
.wrapper {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 20px;
}
.about {
grid-column: 1 / 2;
}
HTML CSS
15
Position items with grid-column and grid-row
CSS Grid
Layouts of the Future
.wrapper {
display: grid;
grid-template-columns: 25% 25% 25% 25%;
grid-gap: 10px;
}
Column 1 Column 4
Column 5 Column 6
Column 2 Column 3
Column 7
16
Position items with grid-column and grid-row
CSS Grid
Layouts of the Future
Column 1
Column 2
Column 3
Column 4
Column 5
Column 6 Column 7
.column-2 {
grid-column: 2 / span 2;
grid-row: 1 / span 2;
}
.column-4 {
grid-row: 2 / span 2;
}
.column-7 {
grid-column: 3 / span 2;
}
17
The FR Unit
CSS Grid
Layouts of the Future
.wrapper {
display: grid;
grid-template-columns: 25% 25% 25% 25%;
grid-gap: 10px;
}
Can be change to:
1fr 1fr 1fr 1fr or
repeat(4, 1fr)
Column 1 Column 4
Column 5 Column 6
Column 2 Column 3
Column 7
18
The FR Unit
CSS Grid
Layouts of the Future
1/4 1/41/4 1/4
grid-template-columns: 1fr 1fr 1fr 1fr;
2/3 1/3
grid-template-columns: 2fr 1fr;
19
The FR Unit
CSS Grid
Layouts of the Future
.wrapper {
display: grid;
grid-template-columns: 25% 25% 25% 25%;
grid-gap: 10px;
}
20
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)
22
Get creative with grid-template-areas
CSS Grid
Layouts of the Future
Hero
small1 small2
small3 small4 small5 small6 small7
med1
grid-template-areas:
"small1 small2 hero hero hero"
"med1 med1 hero hero hero"
"med1 med1 hero hero hero"
"small3 small4 small5 small6 small7";
23
Flexbox CSS Grid
24
Hero
small1 small2
small3 small4 small5 small6 small7
med1
Grid item can be
displayed as a flex
container
25
Hero
small1 small2
small3 small4 small5 small6 small7
med1
Grid item as flex
Align content inside the items:
.hero { align-items: flex-end }
26
http://cssgridgarden.com/
CSS Grid Garden
27
https://gridbyexample.com/
Grid by Example
28
https://codepen.io/collection/nvggZM/
CSS Grid Experiments
29
30
@supports
Also known as feature queries. Modernizr in CSS. Add
stylesheet rules based on whether your browser supports
one or more CSS feature.
31
// fallback code for older browsers
@supports (display: grid) {
// code for newer browsers
// with overrides of the code above
}
32
.wrapper {
max-width: 1440px;
display: grid;
grid-gap: 3px;
grid-template-columns: repeat(2, 1fr);
grid-template-columns: repeat(3, 1fr);
}
.hero-item {
width: 70%;
grid-column: 1 / span 3;
}
Will be ignored by
unsupported
browsers
33
.wrapper {
max-width: 1440px;
display: grid;
grid-gap: 3px;
grid-template-columns: repeat(2, 1fr);
grid-template-columns: repeat(3, 1fr);
}
.hero-item {
width: 70%;
grid-column: 1 / span 3;
}
Will have side effects
on supported
browsers
@supports (display: grid) {
.wrapper > * {
width: auto;
}
}
Reset the width if grid is
supported
34
Do I have to code the same layout twice?
Only if you expect the layout to be the same in all browsers
35
Code
accessible
HTML
Code layout
that works on
all browsers
Progressively
enhance layout
for modern
browsers
36
https://codepen.io/rrenula/full/VMWMWx/
Thumbnail presentation with CSS Grid with
fallback for older browsers
37
https://hacks.mozilla.org/2016/08/using-feature-queries-in-css
Using Feature Queries in CSS
38
aysha.me
@renettarenula
codepen.io/rrenula
Thanks

Más contenido relacionado

Destacado

Building Creative Learning Environments
Building Creative  Learning EnvironmentsBuilding Creative  Learning Environments
Building Creative Learning Environments
Rakuten Group, Inc.
 

Destacado (20)

Rakuten Technology Conference 2017 A Distributed SQL Database For Data Analy...
Rakuten Technology Conference 2017 A Distributed SQL Database  For Data Analy...Rakuten Technology Conference 2017 A Distributed SQL Database  For Data Analy...
Rakuten Technology Conference 2017 A Distributed SQL Database For Data Analy...
 
COBOL to Apache Spark
COBOL to Apache SparkCOBOL to Apache Spark
COBOL to Apache Spark
 
時間がないといって、オペレーション改善を怠るな~オペレーション改善奮闘記~ Emi muroya
時間がないといって、オペレーション改善を怠るな~オペレーション改善奮闘記~ Emi muroya時間がないといって、オペレーション改善を怠るな~オペレーション改善奮闘記~ Emi muroya
時間がないといって、オペレーション改善を怠るな~オペレーション改善奮闘記~ Emi muroya
 
Value Delivery through RakutenBig Data Intelligence Ecosystem and Technology
Value Delivery through RakutenBig Data Intelligence Ecosystem  and  TechnologyValue Delivery through RakutenBig Data Intelligence Ecosystem  and  Technology
Value Delivery through RakutenBig Data Intelligence Ecosystem and Technology
 
What i learned from translation of the sre ryuji tamagawa
What i learned from translation of the sre ryuji tamagawaWhat i learned from translation of the sre ryuji tamagawa
What i learned from translation of the sre ryuji tamagawa
 
Rakutenとsreと私 yanagimoto koichi
Rakutenとsreと私 yanagimoto koichiRakutenとsreと私 yanagimoto koichi
Rakutenとsreと私 yanagimoto koichi
 
AI based language learning tools
AI based language learning toolsAI based language learning tools
AI based language learning tools
 
Predictions and Hard Problems With AI
Predictions and Hard Problems With AIPredictions and Hard Problems With AI
Predictions and Hard Problems With AI
 
WannaEat: A computer vision-based, multi-platform restaurant lookup app
WannaEat: A computer vision-based, multi-platform restaurant lookup appWannaEat: A computer vision-based, multi-platform restaurant lookup app
WannaEat: A computer vision-based, multi-platform restaurant lookup app
 
Rakuten app productivity initiative for developers marcus saw
Rakuten app productivity initiative for developers marcus sawRakuten app productivity initiative for developers marcus saw
Rakuten app productivity initiative for developers marcus saw
 
Java ee7 with apache spark for the world's largest credit card core systems, ...
Java ee7 with apache spark for the world's largest credit card core systems, ...Java ee7 with apache spark for the world's largest credit card core systems, ...
Java ee7 with apache spark for the world's largest credit card core systems, ...
 
cloudera Apache Kudu Updatable Analytical Storage for Modern Data Platform
cloudera Apache Kudu Updatable Analytical Storage for Modern Data Platformcloudera Apache Kudu Updatable Analytical Storage for Modern Data Platform
cloudera Apache Kudu Updatable Analytical Storage for Modern Data Platform
 
Building your own static site Using Hugo
Building your own static site Using HugoBuilding your own static site Using Hugo
Building your own static site Using Hugo
 
RTC 2017 - The Power of Parallelism
RTC 2017 - The Power of ParallelismRTC 2017 - The Power of Parallelism
RTC 2017 - The Power of Parallelism
 
Change the engineer life by batch system renewal
Change the engineer life by batch system renewalChange the engineer life by batch system renewal
Change the engineer life by batch system renewal
 
Realizing AI Conversational Bot
Realizing AI Conversational BotRealizing AI Conversational Bot
Realizing AI Conversational Bot
 
From the browser to the desktop with node js and electron cyril maurel
From the browser to the desktop with node js and electron cyril maurelFrom the browser to the desktop with node js and electron cyril maurel
From the browser to the desktop with node js and electron cyril maurel
 
Deep learning for e-commerce: current status and future prospects
Deep learning for e-commerce: current status and future prospectsDeep learning for e-commerce: current status and future prospects
Deep learning for e-commerce: current status and future prospects
 
Riemannian Geometry in Egison
Riemannian Geometry in EgisonRiemannian Geometry in Egison
Riemannian Geometry in Egison
 
Building Creative Learning Environments
Building Creative  Learning EnvironmentsBuilding Creative  Learning Environments
Building Creative Learning Environments
 

Más de Rakuten Group, Inc.

Más de Rakuten Group, Inc. (20)

コードレビュー改善のためにJenkinsとIntelliJ IDEAのプラグインを自作してみた話
コードレビュー改善のためにJenkinsとIntelliJ IDEAのプラグインを自作してみた話コードレビュー改善のためにJenkinsとIntelliJ IDEAのプラグインを自作してみた話
コードレビュー改善のためにJenkinsとIntelliJ IDEAのプラグインを自作してみた話
 
楽天における安全な秘匿情報管理への道のり
楽天における安全な秘匿情報管理への道のり楽天における安全な秘匿情報管理への道のり
楽天における安全な秘匿情報管理への道のり
 
What Makes Software Green?
What Makes Software Green?What Makes Software Green?
What Makes Software Green?
 
Simple and Effective Knowledge-Driven Query Expansion for QA-Based Product At...
Simple and Effective Knowledge-Driven Query Expansion for QA-Based Product At...Simple and Effective Knowledge-Driven Query Expansion for QA-Based Product At...
Simple and Effective Knowledge-Driven Query Expansion for QA-Based Product At...
 
DataSkillCultureを浸透させる楽天の取り組み
DataSkillCultureを浸透させる楽天の取り組みDataSkillCultureを浸透させる楽天の取り組み
DataSkillCultureを浸透させる楽天の取り組み
 
大規模なリアルタイム監視の導入と展開
大規模なリアルタイム監視の導入と展開大規模なリアルタイム監視の導入と展開
大規模なリアルタイム監視の導入と展開
 
楽天における大規模データベースの運用
楽天における大規模データベースの運用楽天における大規模データベースの運用
楽天における大規模データベースの運用
 
楽天サービスを支えるネットワークインフラストラクチャー
楽天サービスを支えるネットワークインフラストラクチャー楽天サービスを支えるネットワークインフラストラクチャー
楽天サービスを支えるネットワークインフラストラクチャー
 
楽天の規模とクラウドプラットフォーム統括部の役割
楽天の規模とクラウドプラットフォーム統括部の役割楽天の規模とクラウドプラットフォーム統括部の役割
楽天の規模とクラウドプラットフォーム統括部の役割
 
Rakuten Services and Infrastructure Team.pdf
Rakuten Services and Infrastructure Team.pdfRakuten Services and Infrastructure Team.pdf
Rakuten Services and Infrastructure Team.pdf
 
The Data Platform Administration Handling the 100 PB.pdf
The Data Platform Administration Handling the 100 PB.pdfThe Data Platform Administration Handling the 100 PB.pdf
The Data Platform Administration Handling the 100 PB.pdf
 
Supporting Internal Customers as Technical Account Managers.pdf
Supporting Internal Customers as Technical Account Managers.pdfSupporting Internal Customers as Technical Account Managers.pdf
Supporting Internal Customers as Technical Account Managers.pdf
 
Making Cloud Native CI_CD Services.pdf
Making Cloud Native CI_CD Services.pdfMaking Cloud Native CI_CD Services.pdf
Making Cloud Native CI_CD Services.pdf
 
How We Defined Our Own Cloud.pdf
How We Defined Our Own Cloud.pdfHow We Defined Our Own Cloud.pdf
How We Defined Our Own Cloud.pdf
 
Travel & Leisure Platform Department's tech info
Travel & Leisure Platform Department's tech infoTravel & Leisure Platform Department's tech info
Travel & Leisure Platform Department's tech info
 
Travel & Leisure Platform Department's tech info
Travel & Leisure Platform Department's tech infoTravel & Leisure Platform Department's tech info
Travel & Leisure Platform Department's tech info
 
OWASPTop10_Introduction
OWASPTop10_IntroductionOWASPTop10_Introduction
OWASPTop10_Introduction
 
Introduction of GORA API Group technology
Introduction of GORA API Group technologyIntroduction of GORA API Group technology
Introduction of GORA API Group technology
 
100PBを越えるデータプラットフォームの実情
100PBを越えるデータプラットフォームの実情100PBを越えるデータプラットフォームの実情
100PBを越えるデータプラットフォームの実情
 
社内エンジニアを支えるテクニカルアカウントマネージャー
社内エンジニアを支えるテクニカルアカウントマネージャー社内エンジニアを支えるテクニカルアカウントマネージャー
社内エンジニアを支えるテクニカルアカウントマネージャー
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
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
  • 8. 8 Centering elements Candidates for Flexbox Layouts of the Present Column 1
  • 9. 9 Ordering Elements Candidates for Flexbox Layouts of the Present Column 2 Column 4Column 3 Column 1 Can be done through order properties
  • 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
  • 13. 13 <div class="row"> <div class="col s12 l8"> <div class="about"></div> </div> <div class="col s12 l4"> <div class="episodes"></div> </div> </div> VS. <div class="wrapper"> <div class="about"></div> <div class="episodes"></div> </div> Floats CSS Grid
  • 14. 14 <div class="wrapper"> <div class="about"></div> <div class="episodes"></div> </div> .wrapper { display: grid; grid-template-columns: repeat(2, 1fr); grid-gap: 20px; } .about { grid-column: 1 / 2; } HTML CSS
  • 15. 15 Position items with grid-column and grid-row CSS Grid Layouts of the Future .wrapper { display: grid; grid-template-columns: 25% 25% 25% 25%; grid-gap: 10px; } Column 1 Column 4 Column 5 Column 6 Column 2 Column 3 Column 7
  • 16. 16 Position items with grid-column and grid-row CSS Grid Layouts of the Future Column 1 Column 2 Column 3 Column 4 Column 5 Column 6 Column 7 .column-2 { grid-column: 2 / span 2; grid-row: 1 / span 2; } .column-4 { grid-row: 2 / span 2; } .column-7 { grid-column: 3 / span 2; }
  • 17. 17 The FR Unit CSS Grid Layouts of the Future .wrapper { display: grid; grid-template-columns: 25% 25% 25% 25%; grid-gap: 10px; } Can be change to: 1fr 1fr 1fr 1fr or repeat(4, 1fr) Column 1 Column 4 Column 5 Column 6 Column 2 Column 3 Column 7
  • 18. 18 The FR Unit CSS Grid Layouts of the Future 1/4 1/41/4 1/4 grid-template-columns: 1fr 1fr 1fr 1fr; 2/3 1/3 grid-template-columns: 2fr 1fr;
  • 19. 19 The FR Unit CSS Grid Layouts of the Future .wrapper { display: grid; grid-template-columns: 25% 25% 25% 25%; grid-gap: 10px; }
  • 20. 20
  • 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)
  • 22. 22 Get creative with grid-template-areas CSS Grid Layouts of the Future Hero small1 small2 small3 small4 small5 small6 small7 med1 grid-template-areas: "small1 small2 hero hero hero" "med1 med1 hero hero hero" "med1 med1 hero hero hero" "small3 small4 small5 small6 small7";
  • 24. 24 Hero small1 small2 small3 small4 small5 small6 small7 med1 Grid item can be displayed as a flex container
  • 25. 25 Hero small1 small2 small3 small4 small5 small6 small7 med1 Grid item as flex Align content inside the items: .hero { align-items: flex-end }
  • 29. 29
  • 30. 30 @supports Also known as feature queries. Modernizr in CSS. Add stylesheet rules based on whether your browser supports one or more CSS feature.
  • 31. 31 // fallback code for older browsers @supports (display: grid) { // code for newer browsers // with overrides of the code above }
  • 32. 32 .wrapper { max-width: 1440px; display: grid; grid-gap: 3px; grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(3, 1fr); } .hero-item { width: 70%; grid-column: 1 / span 3; } Will be ignored by unsupported browsers
  • 33. 33 .wrapper { max-width: 1440px; display: grid; grid-gap: 3px; grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(3, 1fr); } .hero-item { width: 70%; grid-column: 1 / span 3; } Will have side effects on supported browsers @supports (display: grid) { .wrapper > * { width: auto; } } Reset the width if grid is supported
  • 34. 34 Do I have to code the same layout twice? Only if you expect the layout to be the same in all browsers
  • 35. 35 Code accessible HTML Code layout that works on all browsers Progressively enhance layout for modern browsers