Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS图像大小?_Css_Image - Fatal编程技术网

CSS图像大小?

CSS图像大小?,css,image,Css,Image,那里 #logoWrapper{ background-image: url(../image/bg_img.jpg); height:86px; width:100%; } Q> 如何将图像的大小固定到#logoWapper中,使其与Wapper自动相同 #logoWrapper img{ // not work height:86px; width:100%; } 谢谢大家! 对于CSS3中的背景图像,如果要拉伸而不是重复,可以使用背景大小:10

那里

#logoWrapper{
  background-image: url(../image/bg_img.jpg);
  height:86px;
  width:100%;
  }
Q> 如何将图像的大小固定到#logoWapper中,使其与Wapper自动相同

#logoWrapper img{       // not work
  height:86px;
  width:100%;
  } 

谢谢大家!

对于CSS3中的背景图像,如果要拉伸而不是重复,可以使用
背景大小:100%

记录在这里

或者,您可以将绝对定位的图像分层到相对定位的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>

#包装纸{
位置:相对位置;
...
}
#包装器div,#包装器img{
位置:绝对位置;
顶部:0px;
左:0px;
...
}
这在图片的顶部

请发布cssI想要添加的完整类#logoWrapper img会影响#logoWrapper内的所有标记。因此不会影响css背景图像。在这些情况下,使用img标签最有可能是一种方式。#logoWrapper{背景图像:url(../image/bg_img.jpg);高度:86px;宽度:100%;背景大小:100%;}谢谢!你是说像这样?但不起作用…这将是现代浏览器的编码。。。另一种选择是过去十年的浏览器(不提名字)。@Soonyeong:根据w3schools的说法:“背景大小属性在IE9+、Firefox4+、Opera、Chrome和Safari 5+中都受支持。”如果你想让它在所有浏览器中都起作用,你应该像Wayne建议的那样在div中使用img。还有其他方法吗?没有标签!!哼!你的意思是,没有办法,只有背景重复:重复-x;