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 trial
Michel Thomaz
1,515 PointsWeb-development - fixed content
I have a website and when i zoom out the content separates from the background. How can I make they zoom in and out together, set a default zoom for each browser and make a fixed background? (http://www.djmtz.com)
5 Answers
stoyantodorov
7,666 Pointsbackground: #fff url(http://www.djmtz.com/images/background.png) no-repeat;
stoyantodorov
7,666 PointsBtw, why are you using absolute URLs in your css?
You can change url('http://www.djmtz.com/images/background.png') to url('images/background.png')
Michel Thomaz
1,515 PointsIf i do that it wont work.
stoyantodorov
7,666 Pointsurl('../../../images/background.png') will work
Michel Thomaz
1,515 PointsIt's not working for me. Look this is my current code: body { background: url('.../images/background.png') no-repeat; background-size: auto; font-family: Arial; font-size: 12px; color: #000; margin: 0; }
stoyantodorov
7,666 Pointsbackground-size:100%;
make sure to watch again the videos about relative and absolute paths. that's pretty important. you can use absolute paths for now.
Michel Thomaz
1,515 PointsI mean when I resize only the height it creates a white part at the bottom of the page. Do you know how can I fix that?
Michel Thomaz
1,515 PointsOk so i fixed with the property background-size:100% but suddenly at the bottom at the page there is a white stripe. What can I do sr?
stoyantodorov
7,666 Points background-size:100% 100%;
stoyantodorov
7,666 Pointsalso
background-attachment:fixed;
stoyantodorov
7,666 PointsHere is the whole thing:
body {
background: #fff url(http://www.djmtz.com/images/background.png) no-repeat;
background-size: 100% 100%;
background-attachment:fixed;
font-family: Arial;
font-size: 12px;
color: #000;
margin: 0;
}
Michel Thomaz
1,515 PointsI did that and now its working fine! Thanks a lot master, I really appreciate your help.
Michel Thomaz
1,515 PointsTaking prove that you helped me already, i have another question. I have this website formatted this way but I want to change for mobile and tablets using the @media screen and... but with a completely different style with different pages, is that possible?
stoyantodorov
7,666 PointsIt is. Watch the Treehouse HTML and CSS courses :D
You can overwrite any style in your media queries.
Michel Thomaz
1,515 PointsI have watched already. But in Nick's tutorial he change a few things, not a massive change in the whole style. I want to change the whole website looking, also adding pages. Do you know how can I do that?
stoyantodorov
7,666 PointsJust overwrite the styles that you need to look different in your media queries. You can change whatever you want. Nick changed little things, you can change everything. It's up to you.
Michel Thomaz
1,515 PointsOk thanks. And if Im adding pages where should I put them?
stoyantodorov
7,666 PointsMichel Thomaz
1,515 PointsI know I mean like one website the default I need to leave the way it is but for tablets and smartphones i want to create a whole new including new html and css, adding pages that does not exist in this one. I will send you the links for the website for smartphones I developed.
stoyantodorov
7,666 PointsKeep watching the videos about HTML and CSS and you will learn everything you need. Maybe check out some books too.
The point of media queries is to develop 1 site and change how it looks with the media queries, so it will work for mobile & desktop.
You don't need to create 2 separate sites.
Michel Thomaz
1,515 PointsOk thanks for all! I'll keep watching if I have any doubt I will start a new discussion but thanks for all
stoyantodorov
7,666 Pointsstoyantodorov
7,666 PointsYou may also want to add
background-size: 100%;Michel Thomaz
1,515 PointsMichel Thomaz
1,515 PointsThanks alot!
stoyantodorov
7,666 Pointsstoyantodorov
7,666 PointsI don't think it will work with auto, but you can try.
Michel Thomaz
1,515 PointsMichel Thomaz
1,515 PointsOk thanks alot, but the problem is that when I press SHIFT + COMMAND + PLUS (mac) until it gets to 25% the content get separated from the background. What should I do?
stoyantodorov
7,666 Pointsstoyantodorov
7,666 PointsDid you put the code in your css, where you are styling the body?
Michel Thomaz
1,515 PointsMichel Thomaz
1,515 PointsYes I putted directly on the style.css