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 trialdylan kane
2,094 Pointsbackground properties help
in the background properties video, the teacher, "sorry i forget his name" put in an image and just kept going along and everything was normal for him. when i try to put in an image like he did it dose not work. i have tried a bunch of different ways and im thinking it's the directory that i have screwed up. what im trying to accomplish here is to just put and image in and center it but it wont come in, please help it would be greatly appreciated.
11 Answers
Chase Lee
29,275 PointsBefore the image path. Like this:
background: url('../folder/bg-image');
Does that make sense?
James Barnett
39,199 PointsI'm guessing you've got an issue with file paths, this primer on absolute vs relative file paths should get you pointed in the right direction.
Chase Lee
29,275 PointsIf your style sheet is in a folder then put ../
before that. What ../
is doing is going up one directory and then looking for the img folder and finally the image.
Hope that helps.
dylan kane
2,094 PointsPut ../ before what?
Chase Lee
29,275 PointsTry the background shorthand:
.background{
background: url('../img/background-overlay.jpg') no-repeat center center;
}
Note: I put the extra center
in there just in case.
dylan kane
2,094 Pointsstill isnt working i dont know whats up
Chase Lee
29,275 PointsCan you give me a screenshot of your layout.
dylan kane
2,094 Pointsi emailed them to you
Chase Lee
29,275 PointsWhat the problem looks like is that you are using background-image
instead you should use just background
. Try this:
background: #313131 url('background-overlay.jpg') no-repeat center;
Hope that works.
dylan kane
2,094 Pointsthat didnt work either it just dosnt show up i have no idea what the problem is
Chase Lee
29,275 PointsIn your style links try taking out media=screen
. It's just a guess sometimes that's what makes the difference. Also put this in between your head tags:
<meta http-equiv="Content-Type" content="text/html, charset=utf-8">
dylan kane
2,094 Pointsstill didnt work, im trying everything this is so stupid, its the simplest thing and it wont work!
Chase Lee
29,275 PointsLet me tag Guil Hernandez , maybe he can help.
dylan kane
2,094 Pointsgood idea
Chase Lee
29,275 PointsTry to take out:
type=text/css
In your link tags.
It's a long shot but still trying.
dylan kane
2,094 Pointsdylan kane
2,094 PointsYes thanks a lot man
dylan kane
2,094 Pointsdylan kane
2,094 Pointsits not working for me heres my code
Guil Hernandez
Treehouse TeacherGuil Hernandez
Treehouse TeacherHi dylan kane,
Thanks for posting your code.
Your code is syntactically correct––nothing wrong there. So let's walk through everything that needs to happen in order for the image to appear correctly.
class="background"
attributebackground-overlay.jpg
image needs to be inside a folder named "img"<link rel="stylesheet" href="css/style.css">
– or whatever the style sheet is named.Hope this helps.
dylan kane
2,094 Pointsdylan kane
2,094 Pointsthanks a lot guil! btw your videos are great
Guil Hernandez
Treehouse TeacherGuil Hernandez
Treehouse TeacherThanks dylan kane. Glad to help :)