創作一個和寬度相等的正方形盒子
html代碼:
<div class="box-wrapper">
<div class="box">
</div>
</div>
css代碼:
.box-wrapper{
width: 200px;
background:yellow;
}
.box{
width: 100%;
height: 0;
padding-top: 100%;
background: rgba(0,0,0,.6);
position: relative;
}
最終效果: