left: 50%;
top: 50%;
transform: translate(-50%, -50%);
How it works ?
The CSS left property is based on the size of the parent element. The transform property is based on the size of the target element.
50% to the left moves element to the center of parent screen.
transform -50% moves the element back with respect to half of its own width.
So by this strategy above css align element to the center of screen.
Bhuvan Arora
No comments:
Post a Comment