html - How to fix bootstrap dropdown z-index in the backside of a flipped div? -
i have multiple divs can flipped on hover via css transformation.
on each backside have bootstrap buttongroup dropdown button.
if expand dropdown-menu list hiding behind next div.
how can bring list front?
just listen bootstraps dropdown events , adjust elements z-index. check snippet, should choose bit more precise selectors did though.
$('.flip').hover(function(){ $(this).find('.card').toggleclass('flipped'); }); $('.btn-group').on('show.bs.dropdown', function () { $(this).parentsuntil($( ".face", ".back")).css('zindex', 200); }) $('.btn-group').on('hidden.bs.dropdown', function () { $(this).parentsuntil($( ".face", ".back")).css('zindex', 0); })
body{ padding-top:50px; background: #555; } .flip { -webkit-perspective: 800; perspective: 800; position: relative; text-align: center; } .flip .card.flipped { -webkit-transform: rotatey(-180deg); transform: rotatey(-180deg); } .flip .card { height: 100%; -webkit-transform-style: preserve-3d; -webkit-transition: 0.5s; transform-style: preserve-3d; transition: 0.5s; } .flip .card .face { -webkit-backface-visibility: hidden ; backface-visibility: hidden ; z-index: 2; } .flip .card .front { position: absolute; width: 100%; z-index: 1; } .flip .card .back { -webkit-transform: rotatey(-180deg); transform: rotatey(-180deg); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/> <div class="container"> <div class="row"> <div class="col-sm-12"> <div class="flip"> <div class="card"> <div class="face front"> <div class="well well-sm"> front</div> </div> <div class="face back"> <div class="well well-sm"> <div class="btn-group" role="group" aria-label="..."> <button type="button" class="btn btn-default">1</button> <button type="button" class="btn btn-default">2</button> <div class="btn-group" role="group"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> dropdown <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li><a href="#">dropdown link 1</a></li> <li><a href="#">dropdown link 2</a></li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="col-sm-12"> <div class="flip"> <div class="card"> <div class="face front"> <div class="well well-sm"> front</div> </div> <div class="face back"> <div class="well well-sm"> <div class="btn-group" role="group" aria-label="..."> <button type="button" class="btn btn-default">1</button> <button type="button" class="btn btn-default">2</button> <div class="btn-group" role="group"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> dropdown <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li><a href="#">dropdown link 1</a></li> <li><a href="#">dropdown link 2</a></li> </ul> </div> </div> </div> </div> </div> </div> </div> </div> </div>
have fun!
Comments
Post a Comment