There...
#logoWrapper{
background-image: url(../image/bg_img.jpg);
height:86px;
width:100%;
}
问:如何使图像的大小自动与其包装器#logoWapper相同?
#logoWrapper img{ // not work
height:86px;
width:100%;
}
谢谢!
There...
#logoWrapper{
background-image: url(../image/bg_img.jpg);
height:86px;
width:100%;
}
问:如何使图像的大小自动与其包装器#logoWapper相同?
#logoWrapper img{ // not work
height:86px;
width:100%;
}
谢谢!
如果您想要在CSS3中使用背景图像并且希望拉伸而不是重复,则可以使用background-size: 100%;
此处有文档:http://webdesign.about.com/od/styleproperties/p/blspbgsize.htm
或者,您可以在相对定位的div内添加一个绝对定位的图像,并添加一个额外的包装器。
<style>
#wrapper {
position:relative;
...
}
#wrapper div, #wrapper img {
position:absolute;
top:0px;
left:0px;
...
}
</style>
<div id="wrapper">
<img ... >
<div> this goes on top of image</div>
</div>