Reputation: 1344
I made a header image, but for some reason I can't get it to appear from CSS.
Here's a screenshot:
The header is in the same image directory as the index.html file. The background image is appearing, but not this header. I typed the header twice in the HTML as a div to test it in two different spots to see if it is working, but for some reason it is not showing up, I don't get it lol.
Thanks.
#header {
background-image:url('../emailheader.png');
width:100%;
height:100%;
background-repeat:no-repeat;
}
<div id="header"></div>
Here's an example of it. But I am not sure why it doesn't work.
Upvotes: 1
Views: 629
Reputation: 35572
You need provide height OR it will be dependent on the height of the inner content, which 0
#header {
background-image:url('http://i.imgur.com/ncTiy.png');
width:100%;
background-repeat:no-repeat;
height:200px;
}
Upvotes: 5
Reputation: 11
#header {
background-image:url('../emailheader.png');
width:100%;
height:100%;
background-repeat:no-repeat;
}
html{height:100%;}
body{height:100%;}
May work without the content in the div#header or put some content to the div or use min-height ,it will work.
thankyou
Upvotes: 1
Reputation: 3226
It's cause you're using 100% height and 100% width. Just change it to px values.
Upvotes: 1
Reputation: 33163
Since there's no content in the div its height is zero, so you don't see anything. Add some content to the div or add a height
or min-height
to the CSS.
height:100%
doesn't work because it sets the element's height to equal that of its parent, and the parent's (#container
) height is not set.
See http://tinkerbin.com/QDAEuDUA.
Upvotes: 9
Reputation: 78971
On seing the screenshot of the code. I found two problems.
header
is used to identify two different elements. (Also mentioned by Blaster)However, the main reason why it is not showing up in tinkerbin, is because the div
neither contains any elements nor has a fixed dimensions. Check this update of your bin.
Upvotes: 0