Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSS Layout - Mobile First Design

CSS Layout - Mobile First Design

Basic of CSS relative units & mobile-first design strategy.

Heri Risnanto

April 22, 2020
Tweet

Other Decks in Technology

Transcript

  1. #0 #1 Preview What is Mobile-first? Why Mobile-first? #2 Content

    Coding Inspect Repeat #3 Post Conclusion Q&A, maybe?
  2. Why mobile-first? • Target User • Website traffic stats •

    Faster to deliver production-ready to User • Easier to start writing the layout
  3. Keywords #1 - Units • Font relatives units ◦ em

    -> current element ◦ rem -> root element ◦ ... • Viewport relatives units ◦ vh -> viewport height ◦ vw -> viewport width ◦ ... • Percent % -> parent element • calc () ??
  4. Keywords #1 - Units • Font relatives units ◦ em

    -> current element ◦ rem -> root element ◦ ... • Viewport relatives units ◦ vh -> viewport height ◦ vw -> viewport width ◦ ... • Percent % -> parent element • calc () ??
  5. Keywords #1 - Units • Font relatives units ◦ em

    -> current element ◦ rem -> root element ◦ ... • Viewport relatives units ◦ vh -> viewport height ◦ vw -> viewport width ◦ ... • Percent % -> parent element • calc () ??
  6. Keywords #1 - Units • Font relatives units ◦ em

    -> current element ◦ rem -> root element ◦ ... • Viewport relatives units ◦ vh -> viewport height ◦ vw -> viewport width ◦ ... • Percent % -> parent element • calc () ??
  7. Keywords #1 - Units • Font relatives units ◦ em

    -> current element ◦ rem -> root element ◦ ... • Viewport relatives units ◦ vh -> viewport height ◦ vw -> viewport width ◦ ... • Percent % -> parent element • calc () ??
  8. Keywords #2 - Media query • Mobile-first ◦ @media (min-width:

    768px) {} /* screen width 768px - 1024px */ ◦ @media (min-width: 1024px) {} /* screen width >= 1024px */ ◦ ... • Desktop-first ◦ ... ◦ @media (max-width: 1024px) {} /* screen width 768px - 1024px */ ◦ @media (max-width: 768px) {} /* screen width 0px - 768px */ ◦ ...