Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Layout Basics CSS Layout Project Creating and Styling the Layout Containers

Setting base styles for mobile first approach

I'm quite unsure what styles I should be applying to the base layout and what should be applied to the breakpoint in the media query? What thought process can I use that eases this approach?

2 Answers

Meg Matty
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Meg Matty
Front End Web Development Techdegree Graduate 22,928 Points

The simplest answer I can try to give without more info, is that you build the styles you need to make the site look the way you want in a mobile viewport, then use the breakpoints to add or change whatever styles are not optimal or "break" the way the site looks in larger sizes. So for example, you may be fine with a basic display:block vertical nav in your initial base styles (mobile) but at the media query decide to change these items to a horizontal layout (inline-block).

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 90,705 Points

Hi Benjamin,

The simplest rule of the thumb i can offer is that for mobile screens you're looking for a 1 column layout. So elements of your website will stack on top of each other; your header, navigation and content, and of course only essential content is retained which keeps your website nice and simple.

Then, as the screen gets larger the layout starts to break. and in order to keep it looking nice suddenly more content can be introduced. This will then stack side by side.

For stacking elements vertically you'd use display: block For side by side display you'd use display: inline-block