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

74
Vistas
Link card area that contains a button

The grey area should be an <a> tag link. The black area is a <button> within the grey area. The button should have a onClick action.

When I click anything grey I want to access the <a> tag link. When I click the black area I want to trigger the button action. What is the proper and accessible way to achieve this?

enter image description here

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

0

What about

<style>
    .wrapper{
      position: relative;
    }
    
    a{
      display: block;
      width: 300px;
      height: 150px;
      background-color: lightgray;
      border-radius: 1rem;
    }
    
    button{
      position: absolute;
      bottom: .5rem;
      left: .5rem;
      padding: .5rem;
      background-color: black;
      border-radius: .5rem;
      color: white;
    }
</style>

<div class="wrapper">
   <a href="https://codepen.io/" target="_blank"></a>
   <button type="button" onclick="alert('Fired!')">Button</button>
</div>

See https://codepen.io/nubetonante/pen/PoQaOwO

about 4 years ago · Juan Pablo Isaza Denunciar

0

You could do it with Javascript by the way @ChrisG said, with .stopPropagation() or .preventDefault().

Or if you want to do it with css only, then you could add a card-container, inside an a tag and a button like this:

<div class="container">
   <a href="#"></a>
   <button></button>
</div>

Then make the container position: relative; and the button position:absolute; to position it above the <a> tag. U also will need z-index to place it above.

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