DEV Community

Discussion on: 3 Ways To Center Elements In CSS

Collapse
 
utkarshdhiman48 profile image
Utkarsh Dhiman • Edited
  1. A slight variation in third:

#content{
 /*align content to parent element*/
 position: absolute;
 top: 50%;
 left: 50%;
 transform: translate(-50%, -50%);
 /*for content inside current element set line-height = height of element*/
 text-align: center;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sanchithasr profile image
Sanchithasr

Thank you . Will note that. 😊