Card component (solution 4)
Sample:
When Isn’t Enough: JavaScript Requirements For Accessible Components
Spoiler alert: tooltips, modals, tabs, carousels, and dropdown menus are some of the user interface components that require more than CSS. To ensure accessibility of your interface, JavaScript is a necessary addition to accomplish focus management, respond to keyboard events, and toggle ARIA attributes.
Read “When CSS Isn’t Enough” .
Code:
<div class="card">
<h3>
When Isn’t Enough: JavaScript Requirements For Accessible Components
</h3>
<p class="author">by <a href="https://thinkdobecreate.com/">Stephanie Eckles</a></p>
<img src="/images/demos/card_image.avif" alt="Example dropdown menus from Dribbble, Google search, and GitHub">
<div>
<p>
Spoiler alert: tooltips, modals, tabs, carousels, and dropdown
menus are some of the user interface components that require more
than CSS. To ensure accessibility of your interface, JavaScript
is a necessary addition to accomplish focus management, respond
to keyboard events, and toggle ARIA attributes.
</p>
</div>
<p>
Read
<a class="readmore" href="https://www.smashingmagazine.com/2021/06/css-javascript-requirements-accessible-components/">
“When CSS Isn’t Enough”
</a>.
</p>
</div>
<style>
.card {
--padding: 1rem;
background-color: hsl(222deg 100% 98%);
box-shadow: 0 0 7px 3px hsl(0deg 0% 0% / 10%);
display: grid;
font-family: Seravek, 'Gill Sans Nova', Ubuntu, Calibri, sans-serif;
grid-template-columns: var(--padding) 1fr var(--padding);
line-height: 1.5;
max-width: 23rem;
padding-block-end: var(--padding);
}
.card > * {
grid-column: 2 / -2;
margin: 0 0 0.6em;
}
.card h3 {
line-height: 1.3;
margin-block-end: 0;
}
.card h3 a {
color: initial;
text-decoration: initial;
}
.card :is(img, .img) {
grid-column: 1 / -1;
margin-block-end: var(--padding);
max-width: 100%;
order: -1;
}
.card :last-child {
margin-block-end: 0;
}
.readmore::after {
content: "";
display: block;
inset: 0;
position: absolute;
}
.card .author,
.card > div {
z-index: 1;
}
</style>