html - z-index of child element of a flex item -
i want absolute positioned child element (.tag-preview-container
) of flex item (.image-container
) overlap other elements in dom (for instance header .header
). i'm setting z-index
of absolute positioned element 2 (even 1 should work). however, element doesn't overlap dom element outside flex container(.tags-panel
). in fact, cut off container. not setting z-index of other element in dom, root should stacking context.
<div class="panel-container"> <div class="header"> </div> <div class="tags-panel"> <div class="image-container"> <div class="tag-preview-container"> </div> </div> <div class="image-container"> </div> <div class="image-container"> </div> <div class="image-container"> </div> </div> </div>
this scss code , here's jsfiddle
.panel-container { width: 400px; height: 400px; position: relative; margin: auto; .header { width: 100%; height: 40px; background-color: green; } .tags-panel { position: absolute; background-color: red; top: 40px; bottom: 0px; width: 100%; overflow-y: auto; display: flex; flex-flow: row wrap; align-content: flex-start; } } .image-container { flex: 0 0 33%; box-sizing: border-box; border: 1px solid black; margin-top: 5px; margin-left: 1px; height: 80px; background-color: yellow; position: relative; .tag-preview-container { background-color: black; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 200px; height: 200px; z-index: 2; opacity: 0.5; } }
the z-index
affected overflow
property in .tags-panel
, removing overflow-y: auto;
solve issue. here updated fiddle https://jsfiddle.net/yc5xanax/
overflow-y: auto;
automatically wrap/hide content outside .tags-panel
container.
Comments
Post a Comment