Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

0

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

&:hover{ box-shadow: unset }

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda