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

162
Visualizações
Adds the effect of the hover on the chilled element using the styled component

Good evening everyone. I'm trying to build a component using React and use the Style Component to add the CSS. But when adding the Hover effect to the element (a), the effect is also reflected on all the elements inside the (a). As in the picture enter image description here

<Section>
<PortLogin>
<h1>Welcome to Your Profettional Community</h1>

 <ul>
   <a href="##" ><li href="##">Search For a job</li><i className="fas fa-chevron-right"></i> 
 </a>
   <a  href="##"><li href="##">Find a Person You Know</li><i className="fas fa-chevron-right"> 
 </i></a>
   <a  href="##"><li href="##">Learn a new skill</li><i className="fas fa-chevron-right"></i> 
 </a>
   
 </ul>
 </PortLogin>
 <img src="Img/SectionImg.svg" alt="Img Section "></img>

  </Section>

my styled-components

const Section=styled.div`

display: flex;
justify-content: start;
 flex-wrap:wrap;
 margin-top: 40px;

 & img{
   width: 500px;
   position: absolute;
   right: 0;
     }
 `;

 const PortLogin=styled.div`
 margin-top: 25px;
 display:flex;
 flex-direction:column;
 justify-content:space-around;

 & ul{
  margin-top:50px;
 
     & :hover {
     box-shadow: 3px 3px 8px 2px #00000040;
      }
      }

    & ul>a{
       text-decoration:none;
       padding: 25px 20px;
       margin-bottom: 20px;
       width:70%;
       list-style: none;  
       display: flex;
       justify-content:space-between;
       border: 1px solid #d3cccc;
       border-radius: 13px;
       font-size: larger
     }

      ul li a{
      text-decoration: none;
      color:Black;
     }
      `
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I solved the problem. The solution is very simple. I have to use Direct Child

const PortLogin = styled.div`
   margin-top: 25px;
   display: flex;
   flex-direction: column;
   justify-content: space-around;

    & > ul {
    margin-top: 50px;
     }

     & ul > a {
     text-decoration: none;
     padding: 25px 20px;
     margin-bottom: 20px;
     width: 70%;
     list-style: none;
     display: flex;
     justify-content: space-between;
     border: 1px solid #d3cccc;
     border-radius: 13px;
     font-size: larger;
      }

       ul > li > a {
       text-decoration: none;
       color: Black;
        }
       ul > li > a:hover {
       text-decoration: underline;
        }
         `;
          `
about 4 years ago · Juan Pablo Isaza Relatório

0

You need to move your hover class out of your ul tag (which is wrapping all of the elements within, so all lists and links within it.

I assume you want the links to be hoverable only, so something like this should be more appropriate:

const PortLogin = styled.div`
  margin-top: 25px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;

  & ul {
    margin-top: 50px;
  }

  & ul > a {
    text-decoration: none;
    padding: 25px 20px;
    margin-bottom: 20px;
    width: 70%;
    list-style: none;
    display: flex;
    justify-content: space-between;
    border: 1px solid #d3cccc;
    border-radius: 13px;
    font-size: larger;
  }

  ul li a {
    text-decoration: none;
    color: Black;
  }
  ul li a:hover {
    text-decoration: underline;
  }
`;
`
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