![](/img/trans.png)
[英]Parent div, height not set, over-sizes height by a few pixels to fit child img element height? Why?
[英]why child element <img /> not contains in the parent div width and height?
每个人我尝试的CSS样式如下:
.image{
position: absolute;
width: 100px;
height:100px;
padding: 5px;
margin: 0;
background-color:green;
}
<div class="image">
<img src="http://www.wallpapersgo.com/wp-content/uploads/2010/02/Dodge-Charger-Car.jpg"/>
</div>
问题是,显示的图像大小与原来的大小相同,但预期的大小不是100px * 100px。 CSS风格的新鲜,需要帮助,谢谢!
采用:
.image{
position: absolute;
width: 100px;
height:100px;
padding: 5px;
margin: 0;
background-color:green;
}
.image img {
width: inherit;
height:inherit;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.