codepen
#b { background: orange; box-shadow: 0 0 10px black; z-index: 2; position: relative; } #c { background: red; z-index: 1; position: relative; } ul { list-style: none; margin: 0; padding: 0; z-index: 1; position: relative; } li { display: inline-block; padding: 2px 5px; } .current { background-color: orange; z-index: 3; position: relative; } #d { box-shadow: 0 0 10px black; z-index: 2; }
<div id="a"> <div id="b">bbb</div> <div id="c"> <ul> <li>a</li> <li class="current">b</li> <li>c</li> <li>d</li> </ul> </div> </div> <div id="d">dddd </div>
If you're using z-index, make sure the element has a defined position attribute or it won't work. Wherever you use z-index in your css, define the position of that element. (Absolute, relative, inherit...)
2.1m questions
2.1m answers
60 comments
57.0k users