css - 怎么解决父 DIV 加 img 之后子 DIV 被挤出?
本文介绍了css - 怎么解决父 DIV 加 img 之后子 DIV 被挤出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.A,
.B,
.C {
position: absolute;
}
img {
width: 100%;
height: 100%;
}
.A {
width: 100px;
height: 100px;
background-color: #6495ED;
z-index: 3;
}
.B {
width: 200px;
height: 200px;
background-color: blueviolet;
z-index: 2;
}
.C {
width: 300px;
height: 300px;
background-color: burlywood;
z-index: 1;
}
.father {
width: 500px;
height: 500px;
background-color: brown;
position: relative;
}
</style>
<body>
<div class="father">
<img src="img/SC03C06.jpg"/>
<div class="A">
<img src="img/SC03C06.jpg" />
</div>
<div class="B">
<img src="img/SC03C06.jpg" />
</div>
<div class="C">
<img src="img/SC03C06.jpg" />
</div>
</div>
</body>
![图片描述][1]
解决方案
.A,
.B,
.C {
position: absolute;
top:0;
}
是不是你要的效果?
这篇关于css - 怎么解决父 DIV 加 img 之后子 DIV 被挤出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文