Answers for "centre element in absolute"

CSS
1

centre align in position absolute

position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
Posted by: Guest on February-01-2021
0

center absolute element

.child {
    position: absolute;
    top: 50%;  /* position the top  edge of the element at the middle of the parent */
    left: 50%; /* position the left edge of the element at the middle of the parent */

    transform: translate(-50%, -50%); /* This is a shorthand of
                                         translateX(-50%) and translateY(-50%) */
}
Posted by: Guest on September-15-2021

Code answers related to "centre element in absolute"

Browse Popular Code Answers by Language