Weekend in Lisbon
Three days of tiles, tarts and trams.
A horizontal blog card: the thumbnail pushes in, the headline gets an underline that runs line by line, and the read link arrow nudges. The underline is a background on an inline span.
Also known as: blog post card hover effect, article card css, news card hover.
<a class="hfx-card-blog-post" href="#">
<div class="hfx-card-blog-post-thumb"></div>
<div class="hfx-card-blog-post-body">
<span class="hfx-card-blog-post-tag">Travel</span>
<h3><span>Seven quiet streets to get lost in Lisbon</span></h3>
<span class="hfx-card-blog-post-more">Read story <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h14m-6-6 6 6-6 6"/></svg></span>
</div>
</a>.hfx-card-blog-post {
--c: var(--hfx-color, #3b82f6);
font-size: var(--hfx-size, 16px);
display: flex;
width: 21em;
height: 7.4em;
overflow: hidden;
border: 1px solid color-mix(in srgb, #000 10%, transparent);
border-radius: 0.8em;
background: #fff;
color: #1f2937;
font-family: system-ui, sans-serif;
text-decoration: none;
transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s ease;
}
.hfx-card-blog-post:is(:hover, :focus-visible) {
transform: translateY(-0.2em);
box-shadow: 0 0.9em 1.4em -0.9em color-mix(in srgb, #000 35%, transparent);
}
.hfx-card-blog-post-thumb {
position: relative;
flex: 0 0 7.4em;
overflow: hidden;
}
.hfx-card-blog-post-thumb::before {
content: "";
position: absolute;
inset: 0;
background: radial-gradient(120% 70% at 18% 100%, color-mix(in srgb, var(--c) 75%, #000) 0 50%, transparent 51%),
radial-gradient(140% 80% at 88% 100%, color-mix(in srgb, var(--c) 50%, #fff) 0 50%, transparent 51%),
radial-gradient(circle at 70% 38%, #fff7d6 0 12%, transparent 13%),
linear-gradient(to bottom, color-mix(in srgb, var(--c) 30%, #fff), color-mix(in srgb, var(--c) 55%, #fff));
transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hfx-card-blog-post:is(:hover, :focus-visible) .hfx-card-blog-post-thumb::before {
transform: scale(1.12) rotate(-1.5deg);
}
.hfx-card-blog-post-body {
display: flex;
flex-direction: column;
gap: 0.35em;
min-width: 0;
padding: 0.85em 1em;
}
.hfx-card-blog-post-tag {
font-size: 0.62em;
font-weight: 700;
letter-spacing: 0.1em;
text-transform: uppercase;
color: var(--c);
}
.hfx-card-blog-post h3 {
font-weight: 600;
margin: 0;
font-size: 0.95em;
line-height: 1.35;
}
.hfx-card-blog-post h3 span {
padding-bottom: 0.1em;
background: linear-gradient(var(--c), var(--c)) 0 100% / 0 0.1em no-repeat;
transition: background-size 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hfx-card-blog-post:is(:hover, :focus-visible) h3 span { background-size: 100% 0.1em; }
.hfx-card-blog-post-more {
display: inline-flex;
align-items: center;
gap: 0.35em;
margin-top: auto;
font-size: 0.75em;
font-weight: 600;
color: var(--c);
}
.hfx-card-blog-post-more svg {
width: 1.1em;
height: 1.1em;
fill: none;
stroke: currentColor;
stroke-width: 2.2;
stroke-linecap: round;
stroke-linejoin: round;
transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hfx-card-blog-post:is(:hover, :focus-visible) .hfx-card-blog-post-more svg { transform: translateX(0.35em); }
@media (prefers-reduced-motion: reduce) {
.hfx-card-blog-post, .hfx-card-blog-post *, .hfx-card-blog-post::before, .hfx-card-blog-post::after, .hfx-card-blog-post *::before, .hfx-card-blog-post *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--hfx-color on the element or a parent.
Currently previewing #3b82f6.--hfx-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 16px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.