<div>
<div class="box01">
箱
</div>
<div class="box02">
箱
</div>
</div>
div{
position: relative;
text-align: center;
}
.box01,.box02{
width: 150px;
}
.box01{
position: absolute;
top: 0;
left: 0;
margin-left: 20px;
background-color: lightblue;
}
.box02{
position: absolute;
top: 0;
left: 170px;
margin-left: 50px;/* この値を変更するとbox02が動きます */
background-color: pink;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.