Search code examples
htmlcssz-index

z-index stacking elements outside of what is specified


I used z-index to stack a few input boxes and some text on top of an image which worked how I wanted it to. As I continued on and started the next section of my page it, it moved the next section up behind the image that is using z-index. How do I get my next section to follow the normal flow of the page under the image and not stacked behind it?


Solution

  • The image needs to have position: relative (not absolute) - that way it will remain part of the document flow.