How to center an element with CSS

#1

.center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

#2

.center{
    display: flex;
    align-items: center;
    justify-content: center;
}

#3

.center{ 
    display: grid;
    place-items: center;
}

Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: