有abc三张png图片,如何让它们水平居中并叠加在一起?
<div class="wrapper">
<img class="a">
<img class="b">
<img class="c">
</div>
<style>
.wrapper {
width: 100%;
}
img {
position: absolute;
left: 0;
right: 0;
margin: auto;
}
.a {
width: 30px;
height: 30px;
background: #333;
z-index: 2;
}
.b {
width: 60px;
height: 60px;
background: #666;
z-index: 1;
}
.c {
width: 90px;
height: 90px;
background: #999;
}
</style>
图片显示于屏幕中间并叠加:
<style>
.wrapper {
margin: 0 auto;
width: 100%;
max-width: 1000px;
}
img {
width: 100%;
max-width: 1000px;
float: left;
}
</style>
<div class="wrapper">
<div style="position: relative;">
<img src="a.png">
</div>
<div style="position: absolute;">
<img src="b.png">
</div>
<div style="position: absolute;">
<img src="c.png">
</div>
</div>
13 回答12.7k 阅读
7 回答1.8k 阅读
5 回答1.3k 阅读
3 回答1k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
5 回答2.2k 阅读
先上图,不知道是不是你要的效果
