Center DIV Boxes
assignment for understanding the positioning of div
by Mohammad Faisal
HTML
<div id="wrapper">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
<div class="box5"></div>
</div>
CSS
#wrapper {
display: block;
margin: 0 auto;
margin-top: 5%;
/* top: 50%;*/
width: 500px;
height: 500px;
/* position: absolute;*/
}
#wrapper .box1 {
float: left;
outline: 1px solid #f00;
width: 250px;
height: 250px;
}
#wrapper .box2 {
float: left;
outline: 1px solid #f80;
width: 250px;
height: 250px;
}
#wrapper .box3 {
float: left;
outline: 1px solid #8f0;
width: 250px;
height: 250px;
}
#wrapper .box4 {
float: left;
outline: 1px solid #08f;
width: 250px;
height: 250px;
}
#wrapper .box5 {
position: relative;
width: 250px;
height: 250px;
margin: auto;
top: 25%;
outline: 3px solid #fac;
}