I'm trying to center a div
element, but when I use this:
position: relative;
float: right;
right: 50%;
margin: 0 auto;
I get the following:
It just centers the right edge of the element and everything else goes to left.
Any ideas?
I'm trying to center a div
element, but when I use this:
position: relative;
float: right;
right: 50%;
margin: 0 auto;
I get the following:
It just centers the right edge of the element and everything else goes to left.
Any ideas?
You can try below code:
For Horizontal:
margin:0 auto;
For Horizontal and vertical:
position:absolute;
top:50%;
left:50%;
tranform:translate(-50%, -50%);