有...CSS图像大小?
#logoWrapper{
background-image: url(../image/bg_img.jpg);
height:86px;
width:100%;
}
Q>如何修复图像的尺寸进入#logoWapper其Wapper一样自动?
#logoWrapper img{ // not work
height:86px;
width:100%;
}
谢谢!
有...CSS图像大小?
#logoWrapper{
background-image: url(../image/bg_img.jpg);
height:86px;
width:100%;
}
Q>如何修复图像的尺寸进入#logoWapper其Wapper一样自动?
#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>
#logoWrapper { background-image:url(../ image/bg_img.jpg); height:86px; 宽度:100%; background-size:100%; } 谢谢!你是这个意思吗?但不起作用.... – SoonYeoung
这将是现代浏览器的代码...替代是过去十年的浏览器(不命名)。 – Wayne
@SoonYeng:根据w3schools的说法:“IE9 +,Firefox 4 +,Opera,Chrome和Safari 5+支持后台大小的属性。”如果你想让它在所有的浏览器中都能正常工作,你应该在div里面使用一个img,就像Wayne所说的那样。 – Pianosaurus
请张贴完整的类CSS – kheya
我想补充一点,#logoWrapper IMG影响内部#logoWrapper所有标签..therefore没有CSS背景图片会受到影响。在这些情况下,使用img标签很可能是最好的选择。 – Joonas