Centering with transform and translate in CSS


Center elements perfectly, even when their dimensions are unknown.

Source Code

.center-unknown-size {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments