Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialWade Thomas
Full Stack JavaScript Techdegree Student 9,495 PointsResponsive design
For a more complex website do you have to write a separate index.html file for each resolution, since somethings will be left out on the smart phone site that will appear on the desktop version. Could you show the best way to go about this.
4 Answers
Atanas Sqnkov
14,981 PointsHello Wade!
Wha you want to achieve can be done with media queries.
Media queries are most simply put - a css stylesheet within your css stylesheet :) They are telling the browser how to style your website at a certain device display width;
A media query looks something like this:
div.box {
width: 200px;
height: 200px;
background-color: red
}
@media screen and (max-width: 340px) {
div.box {
display:none;
}
}
In the sample above we have a div with a class="box" , which by default has a width and height of 200px with a red background. What the media query does is, it is telling to the browser - when the browser width gets below 340px, apply a "display: none" to the div with the class of "box". The display: none; property removes the object from the document flow.
It is considered a best practice to place your @media queries at the bottom of your *.css file, after all of your styles.
I hope I made some clarification! Cheers!
Dai Phong
20,395 PointsNo, it's not the best practice, you can you CSS Media Query to archive the best responsive web design
Wade Thomas
Full Stack JavaScript Techdegree Student 9,495 Pointsokay thanks for the speedy response.
Ken Alger
Treehouse TeacherWade;
Many of the Treehouse courses cover, or at least touch on, responsive web design. There is an intermediate level CSS course titled, appropriately enough Build a Responsive Website that covers many of the aspects of taking a site to a responsive one.
Best of luck, Ken
Wade Thomas
Full Stack JavaScript Techdegree Student 9,495 PointsWade Thomas
Full Stack JavaScript Techdegree Student 9,495 PointsWow that's what I was wondering about. Thanks much I'm going to examine this code more closely. and use it for my current project.