html - Can you 'stack' a div *above* a div set to display: table-cell? -
i'm trying create toggle tap on 1 side , background slides on make side 'active'.
to accommodate variable widths, i'm setting 2 sides of toggle using display: table
. works great. add 3rd div
mix act 'active button' slide , forth.
the problem 3rd div. ends being on top of text when need under. hoping z-index solve issue, doesn't. there way accomplish want here?
the html:
<div class="wrapper"> <div class="tbl"> <div class="tbl-cl">1</div> <div class="tbl-cl">2</div> <div class="bgnd"></div> </div> </div>
the css:
.wrapper { float: left; overflow: auto; position: relative; border: 1px solid red; } .tbl { display: table; border: 1px solid blue; } .tbl-cl { display: table-cell; padding: 10px; width: 50%; z-index: 2; } .bgnd { position: absolute; top: 0px; left: 0px; border: 1px solid green; background: rgba(255,0,0,.8); width: 50%; height: 100%; z-index: 1; }
you can realize layout keeping .bgnd
element sibling of css table.
you can shift "slider" right adjusting left offset.
note: keep .bgnd
element child of .tbl
, , css have same effect.
.wrapper { float: left; overflow: auto; position: relative; border: 1px solid red; } .tbl { display: table; border: 1px solid blue; } .tbl-cl { display: table-cell; padding: 10px; width: 50%; z-index: 2; } .bgnd { position: absolute; top: 0px; left: 0px; border: 1px solid green; background: rgba(255, 0, 0, 1); top: 0; left: 0%; /* set 50% slide right */ width: 50%; bottom: 0; z-index: -1; box-sizing: border-box; }
<div class="wrapper"> <div class="tbl"> <div class="tbl-cl">1</div> <div class="tbl-cl">2</div> </div> <div class="bgnd"></div> </div>
Comments
Post a Comment