Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
CSS: Hide box-shadow only when div is getting overflowed

I have a navigation bar with a box shadow. My navigation bar is visible on every page of my website. However, on my Home page, I have a hero section overflowing the Navigation bar. I want the box shadow to disappear there.

Navigation bar on the home page

Navigation bar everywhere else

I tried to give a higher z-index to the content of the Navigation bar but it did not work. If someone could help me out I would be very grateful.

Part of the code for my navigation bar:

header {
    background-color: transparent;
    padding: 0 25px;
    z-index: 1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);


    .link {
        font-weight: 500;
        font-size: 14px;
        padding: 0 2px;
        transition: 0.3s color ease;
        z-index: 110;
        &:hover {
            color: #1eb8b8;
        }
    }
}

Part of the code for my hero section:

.hero-section {
  z-index: 100;
  display: flex;
  justify-content: center;
  background-image: url(../assets/hero.jpg);
  margin-top: -145px;
  height: 115vh;
  width: 100%; 
  background-repeat:no-repeat;
  background-size:cover;
  background-position:center;
  align-items: center;
}

Thank you very much in advance!

Edit: The hero section and the navigation bar are in 2 different files This is the HTML part of the code for the Navigation bar:

<header>
    <nav class="container">
        <div class="nav-links">
            <ul v-show="!mobile">
                <router-link class="link" :to="{name: 'Home'}">Home</router-link>
                <router-link class="link" :to="{name: 'Prints'}">Prints</router-link>
                <router-link class="link" :to="{name: 'Blogs'}">Blogs</router-link>

The links are below the header section so I think that is why the z-index method is not working

For the hero section:

<div class="home">
    <div class="hero-section">
      <h2>Welcome to my website!</h2>
    </div>
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

For z-index to take effect you'll need to apply a position to the elements you want to give a z-index, like so:

.link {
  position: relative;
  z-index: 110;
}

In short, "z-index" only applies to positioned elements. Source: https://developer.mozilla.org/en-US/docs/Web/CSS/z-index

about 4 years ago · Juan Pablo Isaza Report

0

If your header is the Navigation bar Do increase the z index of that element. The higher your z index value is, your element appears on top of stack. Learn more here > https://www.smashingmagazine.com/2009/09/the-z-index-css-property-a-comprehensive-look/

Edit: position is very important as suggested by @Joe Spurling

about 4 years ago · Juan Pablo Isaza Report

0

box-shadow: none or also you can write box-shadow: unset

&:hover{ box-shadow: unset }

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!