![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
So I'm trying to edit the layout I'm currently using. I tweaked some of the original CSS to accomodate my new header. I set the height to 200px since the image height is exactly 200px. But I noticed that there seems to be an extra few couple of pixels and that my header repeats.
This is the relevant CSS:
#header {
background:url("http://a.random-image.net/bcdmonte/batman.jpg") repeat scroll 0 0 transparent;
border:2px dashed #2D231C;
height:200px;
text-align:right;
}
I tried removing
repeat scroll 0 0 transparent
from the CSS but that just resulted in the entire header (plus the border) to disappear. Help?
no subject
Date: 2012-01-01 11:02 am (UTC)no subject
Date: 2012-01-01 12:10 pm (UTC)no subject
Date: 2012-01-01 12:25 pm (UTC)(W3 Schools explains the background repeat options)
no subject
Date: 2012-01-01 12:35 pm (UTC)no subject
Date: 2012-01-01 12:36 pm (UTC)no subject
Date: 2012-01-01 01:23 pm (UTC)no subject
Date: 2012-01-01 01:35 pm (UTC)no subject
Date: 2012-01-01 03:02 pm (UTC)The horizontal repeat to the right is caused by the wide screen. The vertical repeat below is caused by my font size making the header box bigger because it does have some padding declared on it, and the padding is set in ems. Your workaround of the smaller height setting will only work as intended on smaller font sizes.
Here's some code I tested in Web Developer:
#header {
background:url("http://a.random-image.net/bcdmonte/batman.jpg") repeat scroll 0 0 transparent;
border:2px solid #2D231C;
height:200px;
text-align:right;
padding: 0;
background-size: cover;
-moz-background-size: cover;
}
Setting the padding to 0 and the height back to 200px will fix any vertical repeat and show your whole image to viewers no matter their font size.
The background-size property will make the image scale up without losing aspect ratio when the header box is wider than the image. You will always see all of the width of the image, but at very wide screens a bit of the bottom is cut off. If you'd rather that than having the repeat show, you need the two last lines of code to make it work on all browsers, with the exception of IE 8 or lower. In those browsers, the viewer should just see the normal horizontal repeat. If you like the repeat okay, just leave those two lines out.
no subject
Date: 2012-01-01 03:46 pm (UTC)