logo Randthemes.com

How to center div in another div

If you need to center one div in another and you are wondering how to do this here is answer.

By using pure css you can do this. Here is our example of the code using bellow.

Example

We are using this CSS code to do it.

.mail-div{
position: relative;
}

.center-div {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
text-align:center;
}

.center-div:before {
content: ' ';
display: inline-block;
vertical-align: middle;
height: 100%;
}

.center-div .div-text {
padding:20px;
border: 1px solid #000;
vertical-align: middle;
display: inline-block;
}

Leave a Reply

RandThemes.com