How to center a “position: absolute” element

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

    Using left: calc(50% - Wpx/2); where W is the width of the element works for me.

提交回复
热议问题