How to center a “position: absolute” element

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

    Position absolute takes it out of the flow, and places it at 0x0 to the parent ( Last block element to have a position absolute or position relative ).

    I'm not sure what exactly you what you are trying to accomplish, It might be best to set the li to a position:relative and that will center them. Given your current CSS

    Check out http://jsfiddle.net/rtgibbons/ejRTU/ to play with it

提交回复
热议问题