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!
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
Joseph Mercado
5,846 Points@media Issue
I am having issue when scaling my page so that it adjusts to smart phones. Everything but the background images for the header and footer comes out perfect. Why wont the background image show? Here is my css code media section:
@media (max-width: 1024px) {
.primary-content, .secondary-content {
width: 90%;
}
}
@media (max-width: 768px) {
.primary-content, .secondary-content {
width: 100%;
padding: 20px;
border-top: none;
}
.main-header {
max-height: 380px;
padding: 50px 25px 0;
}
h1 {
font-size: 5rem;
line-height: 1.1;
}
.arrow {
display: none;
}
.main-footer {
padding: 20px 0;
}
}
Moderator edited: Markdown added so code renders properly in the forums.

Jennifer Nordell
Treehouse TeacherJoseph Mercado sorry about that. I posted an answer about your media queries being above other rules before I fixed the markdown on your original post. At that time, it did look like they were on top. I see now that they aren't.
2 Answers

Joseph Mercado
5,846 PointsThat did it. Removing fixed solved it. Awesome for the help. :)

Eric Butler
33,512 PointsCheers!

Eric Butler
33,512 PointsJoseph, I think the path you have written in your CSS background declarations -- "../back1.jpg" -- is a broken file path. That would point to an image that's sitting one folder up from wherever this CSS file is sitting, so hypothetically:
|-- index.html
|-- back1.jpg
|-- css/
|-- styles.css
Something tells me your back1.jpg
file is actually in the /imgs/
folder with the rest of your images, so your CSS path should read:
url("../imgs/back1.jpg")
Hope that fixes it for you! Let me know if it does.

Joseph Mercado
5,846 PointsTried that. Still doesn't show the image in the header or footer if the page is loaded on a small screen.

Eric Butler
33,512 PointsTry removing "fixed" from the ends of both background
declarations. I think your image may be falling out of your divs.
Here's a good way to troubleshoot it: I took the HTML and CSS you posted and made a CodePen with it: https://codepen.io/ericbutler555/pen/JyQyYa/?editors=1100#0
Literally the only things I did were (1) changed the URLs for the background images to an image-placeholder link, and (2) removed "fixed" from the declarations. Try adding and removing the "fixed" from the CSS declaration to see how it changes it.
Or if you really wanted to use background-attachment: fixed
effect, then you need to use larger (taller) images so they don't fall out of the divs when you scroll/resize the page.
Joseph Mercado
5,846 PointsJoseph Mercado
5,846 PointsHere is the full CSS
And the HTML
As you can tell, the @media is at the bottom of the CSS file. Any assistance is greatly appreciated.
Thanks.