After trying a lot of tricks I found this perfect solution to keep the element or DIV horizontally and vertically center.
This is worked for me and it’s working in all the main browsers. I’d personally recommend to use the below CSS rules. It’s very simple to apply.
.center{
height: 300px;
position: relative;
border: 3px solid #fff000;
}
.center div {
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
Lorem ipsum dolor sit amet adipiscing elit.
Example:
Lorem ipsum dolor sit amet adipiscing elit.