I need to set the fixed width for the background image. It should work fine in both IE and开发者_C百科 Firefox. How to do get this ?
@Multiplexer: You currently can't set the width/height of the background image, but you can set the width/height of its container.
E.g.
<div style="background: url(someimage.jpg) no-repeat 0 0; height: 300px; width: 400px">
Some content
</div>
If someimage.jpg
is 640x480, only 400px of that width and 300px of that height will be shown. You can move the background around by playing with the background position properties of the CSS -- see http://www.w3schools.com/css/css_background.asp for the full/short-hand reference.
you can use css3 property background-size
, but it's not fully supported yet
https://developer.mozilla.org/en/CSS/-moz-background-size
you can do it with background-size.
enter code here
.myCss
{
background-image:url(image.jpg);
background-repeat:no-repeat;
background size:10% 100%;
}
In size, 10% is width value and 1005 is height value.
精彩评论