Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
Setting an individual div opacity to 1 while parent opacity is set to .7 in React

I have a nav component as shown below with four props that are all booleans used to control UI styling

const Nav = ({ isNav, isVisibleTwo, isVisibleThree, isVisibleFour }) => {
  return (
    <nav className={isNav ? 'bubbs bubbs-enter' : 'bubbs'}>
      <GiHamburgerMenu />
      <a href="#projects-title">
        <div className={isVisibleFour ? 'bubble bubble-active' : 'bubble'}>
          <p>{`//`} P</p>
        </div>
      </a>

      <a href="#resume-title">
        <div className={isVisibleTwo ? 'bubble bubble-active' : 'bubble'}>
          <p>{`//`} R</p>
        </div>
      </a>

      <a href="#contact-me">
        <div className={isVisibleThree ? 'bubble bubble-active' : 'bubble'}>
          <p>{`//`} C</p>
        </div>
      </a>
    </nav>
  )
}

isNav controls whether the nav is visible or not by toggling classes that control opacity.

bubbs-enter sets opacity: 0.7

the problem I'm having is if the bubble-active class is applied I want the opacity of the bubble to be set to 1. Which is not working currently because the nav opacity is set to .7

is there a valid work around for this?

CSS

nav {
  width: 6rem;
  position: sticky;
  top: 0;
  align-self: flex-end;
  z-index: 5;
  height: 100vh;

  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.2rem;
  /* padding-top: 3rem; */
}

.bubbs {
  opacity: 0;
  transition: opacity 400ms ease-in;
}

.bubbs > svg {
  color: white;
  font-size: 1.8rem;
  margin-bottom: .5rem;
}

.bubbs-enter {
  opacity: .7;
}

.bubbs-enter:hover{
  opacity: 1;
  border-left: 1px solid rgba(82, 82, 82, 0.246)
}

.bubble {
  aspect-ratio: 1;
  border: 1px solid rgba(74, 74, 74, 0.216);
  width: 3.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: .5rem 0;
  backdrop-filter: blur(2px);
  cursor: pointer;
  background-color: rgba(28, 28, 28, 0.349);
  transition: all ease 350ms;
}

.bubble:hover {
  transform: scale(1.06);
}

.bubble p {
  color: rgb(240, 240, 240);
  margin: 0;
  font-size: 1.3rem;
  text-transform: capitalize;
  transition: all ease 550ms;
}

.bubble-active {
  background-color: rgb(255, 255, 255);
  transform: scale(1.06);
}

.bubble-active > p {
  color: red;
}

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

What you're trying to achieve is a bit complex to achieve with CSS. You may want to take a look at setting the opacity of each child element than setting the opacity of the parent.

Take a look at the answers in this thread

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda