How to center a “position: absolute” element

后端 未结 26 3309
-上瘾入骨i
-上瘾入骨i 2020-11-21 05:35

I\'m having a problem centering an element that has the attribute position set to absolute. Does anyone know why the images are not centered?

<
26条回答
  •  别跟我提以往
    2020-11-21 05:55

    Or you can now use flex box with postion absolute:

    .parent {
        position: relative;
        display: flex;
        justify-content: center;
    }
    
    .child {
        position: absolute;
    }
    

提交回复
热议问题