How to center a “position: absolute” element

后端 未结 26 3315
-上瘾入骨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

    Div vertically and horizontally aligned center

    top: 0;
    bottom: 0;
    margin: auto;
    position: absolute;
    left: 0;
    right: 0;
    

    Note : Elements should have width and height to be set

提交回复
热议问题