I have a div wrapper and a div row and both have position properties set to relative. The wrapper div has a higher z-index than the inner div and both have background's set, however, the higher z-index background is still below the lower div's background. JS Fiddle Example
.wrapper { position: relative; z-index: 1000; border: 1px solid black; width: 131px; height: 25px; background: repeating-linear-gradient( to right, rgba(255, 0, 0, 0), rgba(255, 0, 0, 0) 10px, black 11px, black 1px); } .row { position: relative; z-index: -1; margin-top: 2px; margin-bottom: 1px; width: 100%; height: 20px; background: linear-gradient( to right, rgba(255, 0, 0, 0) 50%, red 50%); }
<div class="wrapper"> <div class="row"></div> </div>
If you want the grid lines over the red bar, remove the z-index
from the wrapper div:
.wrapper { position: relative; border: 1px solid black; width: 131px; height: 25px; background: repeating-linear-gradient( to right, rgba(255, 0, 0, 0), rgba(255, 0, 0, 0) 10px, black 11px, black 1px); } .row { position: relative; z-index: -1; margin-top: 2px; margin-bottom: 1px; width: 100%; height: 20px; background: linear-gradient( to right, rgba(255, 0, 0, 0) 50%, red 50%); }
<div class="wrapper"> <div class="row"></div> </div>
Remove z-index from wrapper div, and you should be good to go.
.wrapper { position: relative; border: 1px solid black; width: 131px; height: 25px; background: repeating-linear-gradient( to right, rgba(255, 0, 0, 0), rgba(255, 0, 0, 0) 10px, black 11px, black 1px); } .row { position: relative; z-index: -1; margin-top: 2px; margin-bottom: 1px; width: 100%; height: 20px; background: linear-gradient( to right, rgba(255, 0, 0, 0) 50%, red 50%); }
<div class="wrapper"> <div class="row"></div> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.