我在一个 div 中使用了绝对定位的图片,我希望该 div 的高度由该图片定义。但是,由于图片启用了绝对定位,我无法实现这一点。最终,我将在此 div 中使用多个绝对定位的图片,这就是我采取这种方法的原因。有什么想法吗?
HTML:
<div class="image">
<img class="image1" src="image1.jpg" />
</div>
CSS(层叠样式表):
.image {
position:relative;
}
.image1 {
width:100%;
position:absolute;
}
谢谢!