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

257
Vistas
Why is this div not appearing when another div is focused?

I am working on a website, and I ran into a bug with my css. I am wanting a div to show when another div is focused. Why is it not working? Here is my code:

.explore-card-hidden-info {
    display: none;
}

.explore-card-light:focus .explore-card-hidden-info, .explore-card-hidden-info:hover {
    display: block;
}
<div>
    <div className="explore-card-light web-box-hor" style={props.style}>
        <div>
        <img src={props.src} alt="imgex" style={{width: "100%", margin: 'auto', height: 'auto'}}></img>
        </div>
        <div style={{marginLeft: '20px'}}>
            <p className="card-title" style={{textAlign: 'left'}}>{props.title}</p>
            <p className="card-main-text">{props.main}</p>
            <p className="card-footer-text">{props.ex}</p>
        </div>
        <div style={{marginLeft: '20px'}}>
            <p className="explore-card-footer-text" style={{margin: 'none'}}>rates: {props.rate}</p>
            <p className="explore-card-footer-text" style={{margin: 'none'}}>views: {props.views}</p>
            <p className="explore-card-footer-text" style={{margin: 'none'}}>purchases: {props.buys}</p>
        </div>
        <div style={{ padding: '30px 150px' }}>
            <p className="card-title">{props.money}</p>
            <OpBtnOutlineRound text="Buy"></OpBtnOutlineRound>
        </div>
    </div>
    <div className="explore-card-hidden-info">
        <h2>
            I adm hidden!
        </h2>
    </div>
</div>
.explore-card-light {
    background-color: var(--card-bg-light);
    border-radius: 0px 7px 7px 0px;
    padding: 25px;
    width: 95%;
    margin: 20px;
    border-left: 10px solid var(--second);
    position: relative;
    right: 0px;
    transition: all 0.4s ease;
    align-items: center;
    justify-content: space-between;
}
.explore-card-hidden-info {
    display: none;
}

I got it to work with focus on another thing on the website, but it is not wanting to work on this one!

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

0

.explore-card-hidden-info is not a descendant of .explore-card-light, it's an adjacent element. Use + to represent that in CSS.

To make a DIV focusable from the mouse, you need to give it a tabindex.

.explore-card-hidden-info {
    display: none;
}

.explore-card-light:focus + .explore-card-hidden-info {
    display: block;
}
<div>
  <div class="explore-card-light web-box-hor" style={props.style} tabindex="1">
    <div>
      <img src={props.src} alt="imgex" style={{width: "100%", margin: 'auto', height: 'auto'}}></img>
    </div>
    <div style={{marginLeft: '20px'}}>
      <p class="card-title" style={{textAlign: 'left'}}>{props.title}</p>
      <p class="card-main-text">{props.main}</p>
      <p class="card-footer-text">{props.ex}</p>
    </div>
    <div style={{marginLeft: '20px'}}>
      <p class="explore-card-footer-text" style={{margin: 'none'}}>rates: {props.rate}</p>
      <p class="explore-card-footer-text" style={{margin: 'none'}}>views: {props.views}</p>
      <p class="explore-card-footer-text" style={{margin: 'none'}}>purchases: {props.buys}</p>
    </div>
    <div style={{ padding: '30px 150px' }}>
      <p class="card-title">{props.money}</p>
      <OpBtnOutlineRound text="Buy"></OpBtnOutlineRound>
    </div>
  </div>
  <div class="explore-card-hidden-info">
    <h2>
      I adm hidden!
    </h2>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar

0

.explore-card-light:focus~.explore-card-hidden-info, .explore-card-hidden-info:hover {
    display: block;
}

by adding the general sibling selector ~ this should work so change

.explore-card-light:focus.explore-card-hidden-info, .explore-card-hidden-info:hover {
    display: block;
}

TO

.explore-card-light:focus~.explore-card-hidden-info, .explore-card-hidden-info:hover {
    display: block;
}
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