5.5: Absolute
An absolute: element is
<figure class="box-1"></figure>
<figure class="box-2"></figure>
<figure class="box-3"></figure>
<figure class="box-4"></figure>body {
background: #eee;
}
.box-1 {
position: absolute;
width: 250px;
height: 250px;
background: pink;
top: 50%;
left: 50%;
margin-top: -125px;
margin-left: -125px;
}
.box-2 {
position: absolute;
width: 200px;
height: 200px;
background: rgba(199,21,133,1.0);
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -100px;
}
.box-3 {
position: absolute;
width: 150px;
height: 150px;
background: pink;
top: 50%;
left: 50%;
margin-top: -75px;
margin-left: -75px;
}
.box-4 {
position: absolute;
width: 100px;
height: 100px;
background: rgba(199,21,133,1.0);
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -50px;
}Explore more
Challenges
Gold':'
Center the blue square on the document
Blue':'
Center the red square inside the blue square
Last updated