I have divs that are sized according to screen size. On the old version of the site, I was sizing them with specific pixel sizes. I remade it so it would look good on all screen sizes, but I am having trouble with positioning them directly in the center. I am aware of the margin-left and margin-top trick, but that only works with set pixel sizes. Can anyone help me with this?
Asked
Active
Viewed 45 times
0
-
Have you tried the methods mentioned in [this answer](http://stackoverflow.com/questions/19461521/how-to-center-text-horizontally-and-vertically/19461564#19461564)? – Josh Crozier Feb 05 '15 at 04:29
1 Answers
0
you could center div by using
div {
width:50%;
height:25%;
position: absolute;
transform: translateX(-50%) translateY(-50%);
top: 50%;
left: 50%;
}

Sajad Karuthedath
- 14,987
- 4
- 32
- 49