Highly Effective and Maintainable CSS Media Queries

19
Journey to Highly Effective and Maintainable CSS Media Queries

Transcript of Highly Effective and Maintainable CSS Media Queries

Page 1: Highly Effective and Maintainable CSS Media Queries

Journey to Highly Effective

and Maintainable

CSS Media Queries

Page 2: Highly Effective and Maintainable CSS Media Queries

Agenda

1. Intro

2. Where to place them?

3. Maintainable @media query definitions

4. PX vs EM vs REM, which is the best?

5. Choosing the most effective breakpoints

6. Mobile-first?!

Page 3: Highly Effective and Maintainable CSS Media Queries

Intro

Page 4: Highly Effective and Maintainable CSS Media Queries

Where to place @media?

Page 5: Highly Effective and Maintainable CSS Media Queries

Approach #1

Page 6: Highly Effective and Maintainable CSS Media Queries

Approach #2

Page 7: Highly Effective and Maintainable CSS Media Queries

Abstraction!

Page 8: Highly Effective and Maintainable CSS Media Queries

PX vs EM vs REM

Page 9: Highly Effective and Maintainable CSS Media Queries

Choosing the main Breakpoints! (phone, tablet, laptop, desktop)

Approach #1: Most popular screen resolutions in the world!

Approach #2: Copy Bootstrap or Foundation!

Approach #3: Your website visitors most popular screen resolutions!

Page 10: Highly Effective and Maintainable CSS Media Queries

2 main breakpoints: 768px (tablet) & 1024px

(desktop)

Content breaks: at 900px.

Solution #2: Introduce a new breakpoint!(hm, we don’t stick to the main breakpoints for something so general as … our main content)

Issue

Solution #1: Stick to the existing breakpoints!

(but the content is actually okay between 768px to 899px range)

Page 11: Highly Effective and Maintainable CSS Media Queries

Breakpoints should be content-based,not device based!

Page 12: Highly Effective and Maintainable CSS Media Queries

Breakpoints (major) and Tweakpoints (minor)

Page 13: Highly Effective and Maintainable CSS Media Queries

Mobile-first?!

Page 14: Highly Effective and Maintainable CSS Media Queries

Use-case

60% 40%

Page 15: Highly Effective and Maintainable CSS Media Queries

Mobile first!

Page 16: Highly Effective and Maintainable CSS Media Queries

Desktop first...

Page 17: Highly Effective and Maintainable CSS Media Queries

Device Width is not the limit!

Page 18: Highly Effective and Maintainable CSS Media Queries

Follow-up

#2: Blog post (Medium).

#3: StackOverflow Threads.

#1: Feedback.

Page 19: Highly Effective and Maintainable CSS Media Queries