The second div is position: static
(the default) so the z-index does not apply to it.
You need to position (set the position property to anything other than static
, you probably want relative
in this case) anything you want to give a z-index
to.
More Related Contents:
- How to place elements like this
- How to change the style of the title attribute inside an anchor tag?
- Word-wrap in an HTML table
- Vertically align an image inside a div with responsive height
- Last margin / padding collapsing in flexbox / grid layout
- Vertically center two elements within a div [duplicate]
- How to keep origin in center of image in scale animation?
- set content height 100% jquery mobile
- Why is a div with “display: table-cell;” not affected by margin?
- Why isn’t object-fit working in flexbox?
- Resource interpreted as stylesheet but transferred with MIME type text/html (seems not related with web server)
- Best way to include CSS? Why use @import?
- Overflow:hidden dots at the end
- How do I *really* justify a horizontal menu in HTML+CSS?
- Use Font Awesome icon as CSS content
- What is the use of style=”clear:both”?
- How to hide elements without having them take space on the page?
- How can I put an input element on the same line as its label?
- Is inside block correct?
- Can we set style to title tag in header
- How do I disable form fields using CSS?
- Use multiple @font-face rules in CSS
- Text Padding in Select Boxes
- CSS border color switch animation: “from” color not correct
- The border-radius property and border-collapse:collapse don’t mix. How can I use border-radius to create a collapsed table with rounded corners?
- Pixelated edge around a CSS Circle with overflow: hidden;
- How to change font-family of drop down’s list item?
- Can you style ordered list numbers?
- Div with horizontal scrolling only
- Best Way to do Columns in HTML/CSS