How to center a “position: absolute” element

后端 未结 26 3333
-上瘾入骨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 06:10

    If you have set a width you may use:

    position: absolute;
    margin-left: auto;
    margin-right: auto;
    left: 0;
    right: 0;
    text-align: center;
    

提交回复
热议问题