File size: 995 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ---
title: Accessible Clickable Cards
description: Clickable cards with multiple child links
date: 2021-04-21
draft: false
slug: /pensieve/clickable-cards
tags:
- Accessibility
- CSS
---
[Codepen Demo](https://codepen.io/bchiang7/pen/xxRBvgd?editors=1100)
Card layout where the card itself isn't an anchor link, but the whole card is clickable (with a `:before` pseudo element on the main `<a>`). Links inside of the card are still clickable.
## CSS
```css
.grid__item {
&:hover,
&:focus-within {
background-color: #eee;
}
a {
position: relative;
z-index: 1;
}
h2 {
a {
position: static;
&:hover,
&:focus {
color: blue;
}
&:before {
content: '';
display: block;
position: absolute;
z-index: 0;
width: 100%;
height: 100%;
top: 0;
left: 0;
transition: background-color 0.1s ease-out;
background-color: transparent;
}
}
}
}
```
|