Ibrahim Shaikh Ibrahim Shaikh - 2 months ago 8
CSS Question

set div over another Div css

I am creating a web app and I want to open a modal on a button click of

sidenav bar
but the modal is opening behind the
sidenav bar
. I tried
absolute
and
relative
positioning but it's not working either.

sidenav bar

<div class="left-nav clearfix" style="background-color:#00859d; position:relative;">


modal

<div class="container" style="width:100%; margin-left:30%; position:absolute;">


How can I set a div over another div?

Answer

Use the z-index property. Set a z-index: 1 for the nav and set a higher z-index for the modal.