<div class="square" id="s1">1</div>
<div class="square" id="s2">2</div>
<div class="square" id="s3">3</div>
<div class="square" id="s4">4</div>
<div class="square" id="s5">5</div>
<style type="text/css">
.square{
width: 100px;
height: 100px;
background-color: gray;
}
</style>
<style type="text/css">
.square{
position: absolute; /*加入這行*/
width: 100px;
height: 100px;
background-color: gray;
}
</style>
<style type="text/css">
.square{
position: absolute; /*加入這行*/
width: 100px;
height: 100px;
background-color: gray;
}
/* 設定top下一個多80px、設定left下一個多30px */
#s1 {background-color: #00FFFF; top:30px; left:0;}
#s2 {background-color: yellow; top:110px; left:30px;}
#s3 {background-color: red; top:190px; left:60px;}
#s4 {background-color: DodgerBlue; top:270px; left:90px;}
#s5 {background-color: pink; top:350px; left:120px;}
</style>
<style type="text/css">
.square{
position: absolute; /*加入這行*/
width: 100px;
height: 100px;
background-color: gray;
}
/* 設定top下一個多80px、設定left下一個多30px */
#s1 {background-color: #00FFFF; top:30px; left:0;}
#s2 {background-color: yellow; top:110px; left:30px; z-index: 10;}
#s3 {background-color: red; top:190px; left:60px;}
#s4 {background-color: DodgerBlue; top:270px; left:90px; z-index: 10;}
#s5 {background-color: pink; top:350px; left:120px;}
</style>
<style type="text/css">
.square{
position: absolute; /*加入這行*/
width: 100px;
height: 100px;
background-color: yellow;
}
/* 設定top下一個多80px、設定left下一個多30px */
#s1 {background-color: #00FFFF; top:30px; left:0;}
#s2 {background-color: yellow; top:110px; left:30px; z-index: 10;}
#s3 {background-color: red; top:190px; left:60px;}
#s4 {background-color: DodgerBlue; top:270px; left:90px; z-index: 10;}
#s5 {background-color: pink; top:350px; left:120px;}
</style>
<body style="font-size: 2.4rem;">
<div class="square" id="s1">1</div>
<div class="square" id="s2">2</div>
<div class="square" id="s3">3</div>
<div class="square" id="s4">4</div>
<div class="square" id="s5">5</div>
</body>