0

I've got a navigation bar at the top of the page that has a box-shadow, but it doesn't seem to apply to the section element below with a background url. If I comment out the background attribute, the drop shadow is apparent.

Here is the codepen: http://codepen.io/himmel/pen/ByxeGR

Here is the markup:

<div class="header">
  <span class="brand">BRAND</span>
  <ul class="link">
    <li>Home</li>
    <li>About</li>
    <li>Contact</li>
  </ul>
</div>

<div class="blog-container">
  <section>

  </section> 
</div>

And here is the CSS:

body {
  margin: 0;
}

.header {
  display: flex;
  align-items: center;
  font-family: 'Nunito';
  width: 100%;
  background-color: white;
  box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
  height: 4em;
  .brand {
    font-size: 1.3em;
    padding-left: 1em;
  }
  .link {
    display: flex;
    list-style-type: none;
    flex: 1 auto; // stretch to end of width
    justify-content: flex-end;
    margin: 0;
    font-size: 1.3em;
    li {
      padding-right: 1em;
    }
  }
}

.blog-container {
  display: flex;
  flex-flow: column wrap;
  background: url(https://unsplash.imgix.net/photo-1414490929659-9a12b7e31907?q=75&fm=jpg&s=f838066e7aa9eab9d1ccc28fd5ec9574) no-repeat center center fixed;
  background-size: cover;
  section {
    height: 20em;
  }
}

How can I get the drop shadow to appear over the background image?

Himmel
  • 3,629
  • 6
  • 40
  • 77

2 Answers2

1

You could add position: relative; to your .header style.

http://codepen.io/anon/pen/YPLoGN

RouthMedia
  • 401
  • 1
  • 4
  • 17
  • I should've included this, but didn't think it would pertain to the solution. I eventually want the header to retain a fixed position on scroll. – Himmel Feb 25 '15 at 17:02
  • Works with `display: fixed` as well. Thanks for the help. – Himmel Feb 25 '15 at 17:06
1

I forked your example on codepen: Link

position: relative;

You need to add position to the header for it to work properly. (I added z-index, as well but relative seems to fix your issue as well. Credits for author below me)

johniejohnie
  • 523
  • 2
  • 11
  • I should've included this, but didn't think it would pertain to the solution. I eventually want the header to retain a fixed position on scroll. – Himmel Feb 25 '15 at 16:55