Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
When you use a mobile-first layout approach with CSS, you serve the basic layout styles and a minimal amount of code to style a page for a small, mobile device first. Then, using media queries, you add breakpoints that adjust the layout for wider screens and devices.
width
value 70%
allows the container's width to grow and shrink with the browser window size. The max-width
value of 1000px
establishes the maximum size that the growing is allowed to reach.
For example, in a browser viewport that is 1400 pixels or wider, the container will always be 1000 pixels wide and will not grow any wider.
Resources
- Brad Frost - Mobile First Responsive Web Design
- Box-Sizing: The Secret to Simple CSS Layouts
- Take Control of the Box Model with box-sizing
Video review
- In theory, It's easier to build a mobile layout when you're first starting out because you don't have to worry about much of the complex features of wider, desktop layouts.
- Mobile layouts are usually simple one column layouts
- When you use a mobile-first layout approach, you define all the common layout styles before adding any media queries.
-
box-sizing: border-box;
forces any padding and borders into the width and height of an element instead of expanding it.
Related videos
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up