html - CSS - box-shadow not appearing when using :before and z-index -


my goal prevent box-shadow overlapping on top of nearby elements using :before , z-index.

but shadow going underneath container of list item casts because of z-index.

it works fine if parent container body.

is there workaround regarding or should change html , css

html (pug)

div#main   ul     li     li     li 

css (stylus)

#main   background-color lightyellow   height 300px   width 300px  ul   padding 10px    li     background-color lightblue     height 50px     width 50px     margin 10px     position relative    &::before     content ''     box-shadow 0px 0px 15px 20px rgba(0,0,0,0.5)     position absolute     top 0px     right 0px     bottom 0px     left 0px     z-index -1 

you using absolutely positioned pseudo elements without setting position: relative parent, i.e. why causing type of issues haven't set basic css rules better results as:

code snippet

html,  body {    margin: 0;    padding: 0;  }  * {    -webkit-box-sizing: border-box;    -moz-box-sizing: border-box;    box-sizing: border-box;  }  #main {    background-color: lightyellow;    height: 300px;    width: 300px;  }  ul {    padding: 10px;    margin: 0;    position: relative;  }  ul li {    background-color: lightblue;    height: 50px;    width: 50px;    margin: 10px;    position: relative;    overflow: hidden;  }  ul li::before {    content: '';    box-shadow: 0px 0px 15px 20px rgba(0, 0, 0, 0.5);    position: absolute;    top: 0px;    left: 0px;    display: inline-block;    width: 100%;    height: 1px;  }
<div id="main">    <ul>      <li>list01</li>      <li>list02</li>      <li>list03</li>    </ul>  </div>


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -