Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One div above shadow from another div

Tags:

html

css

Let's say I have html code like this:

<div class="container">
   <div class="navbar">Navbar</div>
   <div class="body">Body</div>
</div>

and CSS:

.navbar {
    background-color: green;
    -webkit-box-shadow: 0px 2px 16px 2px rgba(0,0,0,0.75);
    -moz-box-shadow: 0px 2px 16px 2px rgba(0,0,0,0.75);
    box-shadow: 0px 2px 16px 2px rgba(0,0,0,0.75);
}

.body {
    background-color: white;
}

But I can't see shadow, because body is above navbar. How can I fix that?

like image 794
Nominalista Avatar asked Sep 10 '25 22:09

Nominalista


1 Answers

Add position: relative; to .navbar

https://jsfiddle.net/mpn8r6e9/1/

like image 102
FrontDev Avatar answered Sep 13 '25 13:09

FrontDev