Free ToolsGuidesCase StudiesResourcesAboutContact
Get Your Free AI Automation Audit Book a Free 30-Minute Strategy Call
Playground~/frontend Open editor

~/css/hover-effects

35 CSS Hover Effects

33 Pure CSS2 with JSPublished 2026-10-05Free · no sign-up

Hover effects for every part of an interface on one page: everyday UI hovers, link underlines, text reveals, image zooms and overlays, and button hovers. The core set: hover effects for everyday interface parts: a card that lifts, a tile whose shape morphs, a list row with a sliding background, a nav that dims everything except the hovered link, row actions that appear, a settings gear that turns and category tiles that invert their colours.

01. Lift with Growing Shadow

HoverShadow

The basic interface hover: the element rises 4px and its shadow grows softer and wider, as if it moved toward you. Two shadows, a tight one and a blurred one, change together, which looks more natural than one large shadow.

View code
<a class="hv1" href="#docs"><b>Documentation</b><span>Guides, API reference and examples.</span></a>
.hv1 { display: grid; gap: 4px; width: 260px; max-width: 100%; box-sizing: border-box; padding: 18px; border: 1px solid #e4e7ec; border-radius: 14px; background: #fff; color: #475467; font: 14px Inter, system-ui, sans-serif; text-decoration: none; box-shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1); transition: transform .25s ease, box-shadow .25s ease; }
.hv1 b { color: #101828; font-size: 16px; }
.hv1:hover, .hv1:focus-visible { transform: translateY(-4px); box-shadow: 0 4px 6px -2px rgba(16,24,40,.05), 0 16px 24px -6px rgba(16,24,40,.16); }
.hv1:focus-visible { outline: 3px solid #84adff; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .hv1 { transition: box-shadow .25s; } .hv1:hover, .hv1:focus-visible { transform: none; } }

02. Shape Morph on Hover

HoverShape

An icon tile morphs from a squircle to a soft blob shape on hover by transitioning an eight-value border-radius. Each corner gets its own horizontal and vertical radius, which is how CSS makes organic shapes without SVG.

View code
<a class="hv2" href="#ideas" aria-label="Ideas"><span aria-hidden="true">💡</span></a>
.hv2 { display: grid; place-items: center; width: 110px; height: 110px; border-radius: 28% 28% 28% 28% / 28% 28% 28% 28%; background: linear-gradient(135deg, #f59e0b, #db2777); font-size: 40px; text-decoration: none; transition: border-radius .6s cubic-bezier(.2,.8,.2,1), transform .6s; }
.hv2:hover, .hv2:focus-visible { border-radius: 62% 38% 46% 54% / 44% 60% 40% 56%; transform: rotate(8deg); }
.hv2:focus-visible { outline: 3px solid #fcd34d; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .hv2 { transition: none; } .hv2:hover, .hv2:focus-visible { transform: none; } }

03. List Row with Sliding Background

HoverList

Hovering a list row slides a tinted background in from the left and nudges the text right, a clear hover for menus and file lists. The background is a gradient whose size goes from 0 to 100 percent, so there is no extra element.

View code
<ul class="hv3"><li><a href="#f1">Invoice-2041.pdf</a></li><li><a href="#f2">Brand-guide.pdf</a></li><li><a href="#f3">Q3-report.xlsx</a></li></ul>
.hv3 { box-sizing: border-box; width: 260px; max-width: 100%; margin: 0; padding: 6px; list-style: none; border: 1px solid #e4e7ec; border-radius: 12px; background: #fff; font: 600 14px Inter, system-ui, sans-serif; }
.hv3 a { display: block; padding: 11px 12px; border-radius: 8px; color: #344054; text-decoration: none; background: linear-gradient(#eef4ff, #eef4ff) no-repeat 0 0 / 0% 100%; transition: background-size .3s ease, padding .3s ease, color .3s; }
.hv3 a:hover, .hv3 a:focus-visible { background-size: 100% 100%; padding-left: 18px; color: #1d4ed8; }
.hv3 a:focus-visible { outline: 2px solid #528bff; outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) { .hv3 a { transition: color .3s; } }

04. Dim the Others

Hover:has()

When one item in a nav or list is hovered, the rest fade back, which points attention at the hovered one. :has(a:hover) on the list lets CSS style every link that is not hovered, with no script.

View code
<nav class="hv4" aria-label="Footer"><a href="#about">About</a><a href="#careers">Careers</a><a href="#press">Press</a><a href="#contact">Contact</a></nav>
.hv4 { display: flex; flex-wrap: wrap; gap: 4px 18px; font: 800 22px Inter, system-ui, sans-serif; }
.hv4 a { color: #f8fafc; text-decoration: none; transition: opacity .25s; }
.hv4:has(a:hover) a:not(:hover), .hv4:has(a:focus-visible) a:not(:focus-visible) { opacity: .35; }
.hv4 a:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; border-radius: 3px; }

05. Row Actions on Hover or Focus

HoverActions

Edit and delete buttons appear at the end of a row when it is hovered, and also when anything inside it has focus through :focus-within, so keyboard users can reach them. On touch screens they are always visible.

View code
<ul class="hv5"><li><span>Homepage redesign</span><span class="acts"><button aria-label="Edit Homepage redesign">Edit</button><button aria-label="Delete Homepage redesign">Delete</button></span></li><li><span>Spring campaign</span><span class="acts"><button aria-label="Edit Spring campaign">Edit</button><button aria-label="Delete Spring campaign">Delete</button></span></li></ul>
.hv5 { width: 300px; max-width: 100%; margin: 0; padding: 0; list-style: none; font: 14px Inter, system-ui, sans-serif; }
.hv5 li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #e4e7ec; color: #101828; }
.hv5 li:hover { background: #f9fafb; }
.hv5 .acts { display: flex; gap: 4px; opacity: 0; transition: opacity .2s; }
.hv5 li:hover .acts, .hv5 li:focus-within .acts { opacity: 1; }
.hv5 button { padding: 5px 9px; border: 1px solid #d0d5dd; border-radius: 6px; background: #fff; color: #344054; font: 600 12px Inter, system-ui, sans-serif; cursor: pointer; }
.hv5 button:last-child { color: #b42318; }
.hv5 button:focus-visible { outline: 2px solid #528bff; outline-offset: 1px; }
@media (hover: none) { .hv5 .acts { opacity: 1; } }

06. Settings Gear Turns on Hover

HoverIcon

A settings button whose gear icon turns a quarter on hover, a tiny confirmation that the pointer is on a control. The rotation is on the svg only, so the label stays still, and the turn is short enough not to distract.

View code
<button class="hv6"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1"/></svg>Settings</button>
.hv6 { display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; border: 1px solid #3a4670; border-radius: 10px; background: #151b2e; color: #e2e8f0; font: 600 14px Inter, system-ui, sans-serif; cursor: pointer; }
.hv6 svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; transition: transform .45s cubic-bezier(.2,.8,.2,1); }
.hv6:hover svg, .hv6:focus-visible svg { transform: rotate(90deg); }
.hv6:focus-visible { outline: 2px solid #818cf8; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .hv6 svg { transition: none; } }

07. Tile Colour Invert

HoverColour

Category tiles swap their background and text colours on hover, a bold and very readable effect for a grid. Both states pass contrast because they are the same two colours, just exchanged.

View code
<ul class="hv7"><li><a href="#shoes">Shoes</a></li><li><a href="#bags">Bags</a></li><li><a href="#hats">Hats</a></li><li><a href="#belts">Belts</a></li></ul>
.hv7 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 240px; max-width: 100%; margin: 0; padding: 0; list-style: none; font: 800 16px Inter, system-ui, sans-serif; }
.hv7 a { display: grid; place-items: center; height: 70px; border: 2px solid #1e1b4b; border-radius: 12px; background: #fff; color: #1e1b4b; text-decoration: none; transition: background .2s, color .2s; }
.hv7 a:hover, .hv7 a:focus-visible { background: #1e1b4b; color: #fff; }
.hv7 a:focus-visible { outline: 3px solid #818cf8; outline-offset: 2px; }

08. Underline Grows In, Exits Out

LinkUnderline

The underline grows from the left on hover and leaves to the right when the pointer moves away, which feels like it passed through. The trick is changing transform-origin between the two states, so each direction scales from a different side.

View code
<p class="lk1">Read our <a href="#guide">shipping guide</a> before you order.</p>
.lk1 { margin: 0; color: #344054; font: 18px Inter, system-ui, sans-serif; }
.lk1 a { position: relative; color: #1d4ed8; font-weight: 600; text-decoration: none; }
.lk1 a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: currentColor; transform: scaleX(0); transform-origin: right; transition: transform .3s ease; }
.lk1 a:hover::after, .lk1 a:focus-visible::after { transform: scaleX(1); transform-origin: left; }
.lk1 a:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 3px; border-radius: 2px; }
@media (hover: none) { .lk1 a { text-decoration: underline; } .lk1 a::after { display: none; } }

09. Highlight Rises Behind the Link

LinkBackground

A thin coloured underline at rest becomes a full highlight behind the text on hover, because the background gradient's height animates from 2px to 100 percent. The text colour stays dark on the pale highlight for contrast.

View code
<p class="lk2">Browse the <a href="#archive">full archive</a> or <a href="#search">search</a>.</p>
.lk2 { margin: 0; color: #344054; font: 18px Inter, system-ui, sans-serif; }
.lk2 a { color: #101828; font-weight: 600; text-decoration: none; background: linear-gradient(#a7f3d0, #a7f3d0) 0 100% / 100% 2px no-repeat; transition: background-size .25s ease; }
.lk2 a:hover, .lk2 a:focus-visible { background-size: 100% 100%; }
.lk2 a:focus-visible { outline: 2px solid #059669; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .lk2 a { transition: none; } }

10. Link with Moving Arrow

LinkIcon

A standalone call-to-action link whose arrow nudges right on hover, hinting at going somewhere. The arrow is an aria-hidden span so the accessible name is just the words, and the movement is a transform on the arrow only.

View code
<a class="lk3" href="#case-study">Read the case study <span aria-hidden="true">&rarr;</span></a>
.lk3 { display: inline-flex; align-items: center; gap: 6px; color: #93c5fd; font: 700 17px Inter, system-ui, sans-serif; text-decoration: none; }
.lk3 span { transition: transform .25s ease; }
.lk3:hover span, .lk3:focus-visible span { transform: translateX(5px); }
.lk3:hover { color: #bfdbfe; }
.lk3:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; border-radius: 3px; }
@media (prefers-reduced-motion: reduce) { .lk3 span { transition: none; } }

11. Underline Offset Shift

LinkUnderline

A native text underline that moves closer and thickens on hover, using text-underline-offset and text-decoration-thickness. Real underlines respect descenders with text-decoration-skip-ink, which a pseudo-element underline cannot do.

View code
<p class="lk4">Questions? <a href="#help">Visit the help centre</a> or reply to any email.</p>
.lk4 { margin: 0; color: #344054; font: 18px Inter, system-ui, sans-serif; }
.lk4 a { color: #6d28d9; font-weight: 600; text-decoration: underline; text-decoration-color: #c4b5fd; text-decoration-thickness: 1px; text-underline-offset: 6px; text-decoration-skip-ink: auto; transition: text-underline-offset .2s, text-decoration-thickness .2s, text-decoration-color .2s; }
.lk4 a:hover, .lk4 a:focus-visible { text-underline-offset: 3px; text-decoration-thickness: 3px; text-decoration-color: #6d28d9; }
.lk4 a:focus-visible { outline: 2px solid #6d28d9; outline-offset: 3px; border-radius: 2px; }

12. External Link with Icon

LinkExternal

Links to other sites get a small arrow-out icon that lifts on hover, added automatically with an attribute selector on href^="http". A visually hidden note says it opens another website, which matters when the link leaves your site.

View code
<p class="lk5">Built with <a href="https://developer.mozilla.org/">MDN's guides<span class="sr"> (external site)</span></a> as reference.</p>
.lk5 { margin: 0; color: #cbd5e1; font: 17px Inter, system-ui, sans-serif; }
.lk5 a { color: #67e8f9; font-weight: 600; text-underline-offset: 3px; }
.lk5 a[href^="http"]::after { content: "↗"; display: inline-block; margin-left: 2px; font-size: .8em; transition: transform .2s ease; }
.lk5 a[href^="http"]:hover::after, .lk5 a[href^="http"]:focus-visible::after { transform: translate(2px, -2px); }
.lk5 .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.lk5 a:focus-visible { outline: 2px solid #67e8f9; outline-offset: 2px; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) { .lk5 a::after { transition: none; } }

13. Nav Links with a Sliding Pill

LinkNavigation

A pill-shaped highlight slides between nav links to follow the hovered or focused one, and settles on the current page when the pointer leaves. A few lines of script measure the link and move one absolutely positioned pill with transform.

View code
<nav class="lk6" aria-label="Main"><span class="pill" aria-hidden="true"></span><a href="#home" aria-current="page">Home</a><a href="#pricing">Pricing</a><a href="#blog">Blog</a><a href="#contact">Contact</a></nav>
.lk6 { position: relative; display: flex; gap: 2px; padding: 5px; border: 1px solid #e4e7ec; border-radius: 999px; background: #fff; font: 600 14px Inter, system-ui, sans-serif; }
.lk6 a { position: relative; z-index: 1; padding: 8px 12px; border-radius: 999px; color: #344054; text-decoration: none; }
.lk6 a[aria-current] { color: #101828; }
.lk6 .pill { position: absolute; top: 5px; left: 0; height: calc(100% - 10px); border-radius: 999px; background: #f2f4f7; transition: transform .3s cubic-bezier(.2,.8,.2,1), width .3s cubic-bezier(.2,.8,.2,1); }
.lk6 a:focus-visible { outline: 2px solid #528bff; outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .lk6 .pill { transition: none; } }
var nav = document.querySelector('.lk6'), pill = nav.querySelector('.pill'), cur = nav.querySelector('[aria-current]');
function to(a) { pill.style.width = a.offsetWidth + 'px'; pill.style.transform = 'translateX(' + a.offsetLeft + 'px)'; }
nav.querySelectorAll('a').forEach(function (a) { a.addEventListener('mouseenter', function () { to(a); }); a.addEventListener('focus', function () { to(a); }); });
nav.addEventListener('mouseleave', function () { to(cur); }); nav.addEventListener('focusout', function (e) { if (!nav.contains(e.relatedTarget)) to(cur); });
to(cur);

14. Dotted Underline Turns Solid

LinkGlossary

A glossary-style term with a dotted underline that turns solid and changes colour on hover, a convention readers recognise as a definition link. It uses text-decoration-style, so it wraps across lines correctly, unlike a border-bottom.

View code
<p class="lk7">Our checkout passes <a href="#glossary-pci">PCI DSS</a> checks every quarter.</p>
.lk7 { margin: 0; color: #cbd5e1; font: 17px Inter, system-ui, sans-serif; }
.lk7 a { color: #fde68a; text-decoration: underline dotted #fde68a; text-decoration-thickness: 2px; text-underline-offset: 4px; transition: color .2s, text-decoration-color .2s; }
.lk7 a:hover, .lk7 a:focus-visible { color: #fbbf24; text-decoration-style: solid; text-decoration-color: #fbbf24; }
.lk7 a:focus-visible { outline: 2px solid #fbbf24; outline-offset: 2px; border-radius: 2px; }

15. Colour Fill Sweep on Hover

TextHover

Hovering a heading sweeps a second colour across the letters from left to right. The heading has a two-colour background split at 50 percent, clipped to the text and twice as wide, and hover shifts its position. Focus within the card triggers it too.

View code
<a class="th1" href="#process"><span>Our process</span></a>
.th1 { font: 900 40px Inter, system-ui, sans-serif; text-decoration: none; color: #101828; }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .th1 span { background: linear-gradient(90deg, #db2777 50%, #101828 50%) 100% 0 / 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; transition: background-position .5s ease; }
  .th1:hover span, .th1:focus-visible span { background-position: 0 0; }
}
.th1:focus-visible { outline: 3px solid #f9a8d4; outline-offset: 4px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .th1 span { transition: none; } }

16. Text Slides Up to a Copy

TextHover

On hover the label slides up out of view and an identical copy slides up into its place, a crisp effect for nav items and buttons. The copy is a pseudo-element reading the text from a data attribute, so it is not read twice by screen readers.

View code
<a class="th2" href="#work" data-t="View our work"><span>View our work</span></a>
.th2 { position: relative; display: inline-block; overflow: hidden; height: 1.25em; color: #f8fafc; font: 800 28px/1.25 Inter, system-ui, sans-serif; text-decoration: none; }
.th2 span, .th2::after { display: block; transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.th2::after { content: attr(data-t); position: absolute; left: 0; top: 100%; color: #22d3ee; }
.th2:hover span, .th2:hover::after, .th2:focus-visible span, .th2:focus-visible::after { transform: translateY(-100%); }
.th2:focus-visible { outline: 2px solid #22d3ee; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .th2 span, .th2::after { transition: none; } }

17. Letter Spacing Expand

TextTypography

Uppercase text spreads its letters apart on hover, a refined effect for fashion and luxury menus. The link has a fixed width and centred text so expanding letters do not push the items around it.

View code
<nav class="th3" aria-label="Collections"><a href="#women">Women</a><a href="#men">Men</a><a href="#home">Home</a></nav>
.th3 { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; box-sizing: border-box; max-width: 100%; }
.th3 a { width: 96px; padding: 8px 0; color: #1c1917; font: 600 13px Inter, system-ui, sans-serif; text-align: center; text-decoration: none; text-transform: uppercase; letter-spacing: .08em; transition: letter-spacing .35s ease, color .35s; }
.th3 a:hover, .th3 a:focus-visible { letter-spacing: .3em; color: #9a3412; }
.th3 a:focus-visible { outline: 2px solid #9a3412; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .th3 a { transition: color .35s; } }

18. 3D Text Shadow Lift

TextShadow

Stacked text-shadows build a solid 3D extrusion under the word, and on hover the text rises while the extrusion lengthens. Each shadow layer is 1px further down and to the right, and the hover state adds layers for the deeper look.

View code
<a class="th4" href="#arcade">ARCADE</a>
.th4 { display: inline-block; color: #fde047; font: 900 54px Inter, system-ui, sans-serif; text-decoration: none; text-shadow: 1px 1px #ca8a04, 2px 2px #ca8a04, 3px 3px #a16207; transition: transform .25s ease, text-shadow .25s ease; }
.th4:hover, .th4:focus-visible { transform: translate(-3px, -3px); text-shadow: 1px 1px #ca8a04, 2px 2px #ca8a04, 3px 3px #ca8a04, 4px 4px #a16207, 5px 5px #a16207, 6px 6px #854d0e; }
.th4:focus-visible { outline: 2px solid #fde047; outline-offset: 6px; }
@media (prefers-reduced-motion: reduce) { .th4 { transition: none; } .th4:hover, .th4:focus-visible { transform: none; } }

19. Letters Flip One by One

Text3D

Each letter turns a full circle on the y-axis in sequence when the word is hovered. Letters are spans with an index for the delay, wrapped in an element with an aria-label holding the whole word, and the spans are aria-hidden.

View code
<a class="th5" href="#studio" aria-label="Studio"><span aria-hidden="true"><i style="--i:0">S</i><i style="--i:1">t</i><i style="--i:2">u</i><i style="--i:3">d</i><i style="--i:4">i</i><i style="--i:5">o</i></span></a>
.th5 { color: #4338ca; font: 900 48px Inter, system-ui, sans-serif; text-decoration: none; }
.th5 i { display: inline-block; font-style: normal; transition: transform .5s ease; transition-delay: calc(var(--i) * 50ms); }
.th5:hover i, .th5:focus-visible i { transform: rotateY(360deg); }
.th5:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 4px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .th5 i { transition: none; } .th5:hover i, .th5:focus-visible i { transform: none; } }

20. Strike-Through Draw

TextLine

A line draws through the old price when the line is hovered, useful for prices, to-do items or a playful menu. It is decoration only, since the words Was and now already carry the meaning. The line is a pseudo-element scaled from zero along the x axis with a slight skew.

View code
<p class="th6">Was <span>$120</span> now <b>$84</b></p>
.th6 { margin: 0; color: #cbd5e1; font: 600 22px Inter, system-ui, sans-serif; }
.th6 span { position: relative; color: #e2e8f0; cursor: default; }
.th6 span::after { content: ""; position: absolute; left: -4px; right: -4px; top: 52%; height: 3px; border-radius: 2px; background: #f43f5e; transform: scaleX(0) rotate(-6deg); transform-origin: left; transition: transform .35s ease; }
.th6:hover span::after { transform: scaleX(1) rotate(-6deg); }
.th6 b { color: #4ade80; }
@media (prefers-reduced-motion: reduce) { .th6 span::after { transition: none; } }

21. Hidden Word Revealed on Hover

TextReveal

Part of the headline is covered by a solid block that slides away on hover or focus to reveal the punchline. The hidden words are still real text in the DOM, so screen readers read the full sentence whether or not the block has moved.

View code
<p class="th7" tabindex="0">We build stores that <span class="w">actually sell<span class="cov" aria-hidden="true"></span></span>.</p>
.th7 { width: 300px; max-width: 100%; margin: 0; color: #101828; font: 800 26px/1.3 Inter, system-ui, sans-serif; }
.th7 .w { position: relative; display: inline-block; color: #7c3aed; }
.th7 .cov { position: absolute; inset: -2px -4px; background: #101828; border-radius: 4px; transform-origin: right; transition: transform .45s cubic-bezier(.7,0,.3,1); }
.th7:hover .cov, .th7:focus-visible .cov { transform: scaleX(0); }
.th7:focus-visible { outline: 3px solid #c4b5fd; outline-offset: 4px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .th7 .cov { transition: none; } }

22. Zoom Inside the Frame

ImageHover

The image scales up slightly inside a fixed frame on hover, the most common image hover there is. The frame has overflow: hidden and the link around it carries the focus style, so the same zoom shows for keyboard users.

View code
<a class="ih1" href="#journal"><span class="fr"><span class="im" role="img" aria-label="Coffee and notebook on a desk"></span></span><span class="t">How we plan a product launch</span></a>
.ih1 { display: grid; gap: 8px; width: 260px; max-width: 100%; color: #101828; font: 700 15px Inter, system-ui, sans-serif; text-decoration: none; }
.ih1 .fr { overflow: hidden; border-radius: 14px; }
.ih1 .im { display: block; aspect-ratio: 16 / 10; background: radial-gradient(circle at 30% 60%, #78350f 0 14%, transparent 15%), radial-gradient(ellipse at 70% 50%, #fef3c7 0 24%, transparent 25%), #d6c3a5; transition: transform .5s ease; }
.ih1:hover .im, .ih1:focus-visible .im { transform: scale(1.07); }
.ih1:focus-visible { outline: 3px solid #84adff; outline-offset: 4px; border-radius: 14px; }
@media (prefers-reduced-motion: reduce) { .ih1 .im { transition: none; } }

23. Grayscale to Colour

ImageFilter

Team photos sit in grayscale and come to life in colour when hovered or focused, a neat way to keep a grid of mixed photos looking consistent. It is a filter transition, so the image itself never changes.

View code
<ul class="ih2"><li><a href="#ines"><span class="im" style="--g:linear-gradient(160deg,#fcd34d,#ea580c)"></span><span>Inês</span></a></li><li><a href="#tom"><span class="im" style="--g:linear-gradient(160deg,#67e8f9,#2563eb)"></span><span>Tom</span></a></li><li><a href="#yara"><span class="im" style="--g:linear-gradient(160deg,#f9a8d4,#9333ea)"></span><span>Yara</span></a></li></ul>
.ih2 { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 0; padding: 0; list-style: none; box-sizing: border-box; max-width: 100%; font: 600 13px Inter, system-ui, sans-serif; }
.ih2 a { display: grid; gap: 6px; color: #e2e8f0; text-decoration: none; text-align: center; }
.ih2 .im { display: block; width: 86px; aspect-ratio: 3 / 4; border-radius: 12px; background: var(--g); filter: grayscale(1) contrast(.9); transition: filter .4s ease; }
.ih2 a:hover .im, .ih2 a:focus-visible .im { filter: none; }
.ih2 a:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; border-radius: 12px; }

24. Caption Slides Up Over the Image

ImageCaption

A caption panel slides up from the bottom edge on hover or focus, with a gradient behind it so the white text stays readable over any photo. On touch screens the caption is always visible.

View code
<a class="ih3" href="#villa"><span class="im" role="img" aria-label="White villa above the sea"></span><span class="cap"><b>Villa Azul</b> Sleeps 6 · from €240 a night</span></a>
.ih3 { position: relative; display: block; width: 260px; max-width: 100%; overflow: hidden; border-radius: 14px; font-family: Inter, system-ui, sans-serif; text-decoration: none; }
.ih3 .im { display: block; aspect-ratio: 4 / 3; background: linear-gradient(#bae6fd 45%, #0ea5e9 45% 70%, #0369a1 70%); }
.ih3 .cap { position: absolute; left: 0; right: 0; bottom: 0; display: grid; gap: 2px; padding: 28px 14px 12px; background: linear-gradient(transparent, rgba(2,6,23,.85)); color: #e2e8f0; font-size: 13px; transform: translateY(100%); transition: transform .35s ease; }
.ih3 .cap b { color: #fff; font-size: 16px; }
.ih3:hover .cap, .ih3:focus-visible .cap { transform: none; }
.ih3:focus-visible { outline: 3px solid #84adff; outline-offset: 3px; }
@media (hover: none) { .ih3 .cap { transform: none; } }
@media (prefers-reduced-motion: reduce) { .ih3 .cap { transition: none; } }

25. Overlay with Zoom Icon

ImageOverlay

A dark overlay and a magnifier icon fade in over the image to say it opens larger. The link's accessible name says Open larger image of a red tram, which describes both the image and what the click does.

View code
<a class="ih4" href="#tram-large" aria-label="Open larger image of a red tram"><span class="im" aria-hidden="true"></span><span class="ov" aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="6"/><path d="M20 20l-4.5-4.5M11 8v6M8 11h6"/></svg></span></a>
.ih4 { position: relative; display: block; width: 240px; max-width: 100%; overflow: hidden; border-radius: 14px; }
.ih4 .im { display: block; aspect-ratio: 1; background: linear-gradient(#fde68a 0 40%, #dc2626 40% 75%, #44403c 75%); }
.ih4 .ov { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(2,6,23,.55); opacity: 0; transition: opacity .3s; }
.ih4 svg { width: 40px; height: 40px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; transform: scale(.7); transition: transform .3s; }
.ih4:hover .ov, .ih4:focus-visible .ov { opacity: 1; } .ih4:hover svg, .ih4:focus-visible svg { transform: none; }
.ih4:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .ih4 .ov, .ih4 svg { transition: none; } }

26. Others Blur When One Is Hovered

ImageGallery

In a gallery, hovering one image blurs and dims the rest so the chosen one stands out. :has() on the grid detects that something inside is hovered and styles every image that is not, with no JavaScript.

View code
<ul class="ih5"><li><a href="#p1" style="--g:linear-gradient(135deg,#fb923c,#be123c)" aria-label="Photo 1"></a></li><li><a href="#p2" style="--g:linear-gradient(135deg,#34d399,#0f766e)" aria-label="Photo 2"></a></li><li><a href="#p3" style="--g:linear-gradient(135deg,#818cf8,#4338ca)" aria-label="Photo 3"></a></li><li><a href="#p4" style="--g:linear-gradient(135deg,#facc15,#a16207)" aria-label="Photo 4"></a></li></ul>
.ih5 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 240px; max-width: 100%; margin: 0; padding: 0; list-style: none; }
.ih5 a { display: block; aspect-ratio: 1; border-radius: 12px; background: var(--g); transition: filter .3s, opacity .3s, transform .3s; }
.ih5:has(a:hover) a:not(:hover), .ih5:has(a:focus-visible) a:not(:focus-visible) { filter: blur(2px) grayscale(.6); opacity: .6; }
.ih5 a:hover, .ih5 a:focus-visible { transform: scale(1.04); }
.ih5 a:focus-visible { outline: 3px solid #528bff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .ih5 a { transition: none; } .ih5 a:hover, .ih5 a:focus-visible { transform: none; } }

27. Duotone on Hover

ImageBlend

A colour wash in two brand colours sits over the image with mix-blend-mode, turning any photo into an on-brand duotone; hover lifts the wash to show the original. It is a common way to make stock photos feel part of one design.

View code
<a class="ih6" href="#story"><span class="im" role="img" aria-label="Mountain lake at dawn"></span><span class="wash" aria-hidden="true"></span><span class="t">Read the story</span></a>
.ih6 { position: relative; display: block; width: 260px; max-width: 100%; overflow: hidden; border-radius: 14px; font-family: Inter, system-ui, sans-serif; text-decoration: none; }
.ih6 .im { display: block; aspect-ratio: 4 / 3; background: linear-gradient(#fde68a, #fb923c 35%, #1e3a8a 36% 60%, #0f172a 61%); }
.ih6 .wash { position: absolute; inset: 0; background: linear-gradient(135deg, #db2777, #312e81); mix-blend-mode: color; transition: opacity .4s; }
.ih6 .t { position: absolute; left: 12px; bottom: 12px; padding: 6px 10px; border-radius: 6px; background: #fff; color: #0f172a; font-weight: 700; font-size: 13px; }
.ih6:hover .wash, .ih6:focus-visible .wash { opacity: 0; }
.ih6:focus-visible { outline: 3px solid #f9a8d4; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .ih6 .wash { transition: none; } }

28. Inset Frame Appears

ImageBorder

A thin white frame draws itself inside the image edge on hover, a gallery-style touch for portfolios. The frame is an outline on a pseudo-element with a negative offset, scaling in from slightly larger, so it never affects the layout.

View code
<a class="ih7" href="#series"><span class="im" role="img" aria-label="Abstract blue and orange painting"></span></a>
.ih7 { position: relative; display: block; width: 240px; max-width: 100%; overflow: hidden; border-radius: 6px; }
.ih7 .im { display: block; aspect-ratio: 4 / 5; background: radial-gradient(circle at 30% 30%, #fb923c 0 22%, transparent 23%), radial-gradient(circle at 70% 70%, #1d4ed8 0 30%, transparent 31%), #f1f5f9; }
.ih7::after { content: ""; position: absolute; inset: 14px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.08); opacity: 0; transform: scale(1.08); transition: opacity .35s, transform .35s; pointer-events: none; }
.ih7:hover::after, .ih7:focus-visible::after { opacity: 1; transform: none; }
.ih7:focus-visible { outline: 3px solid #528bff; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .ih7::after { transition: none; } }

29. Fill from the Bottom

ButtonHover

An outlined button fills with colour from the bottom edge up on hover and focus, and the text colour flips to stay readable. The fill is a pseudo-element scaled on the y axis, kept behind the label with a negative z-index inside an isolated button.

View code
<button class="bh1">Explore the range</button>
.bh1 { position: relative; isolation: isolate; overflow: hidden; padding: 14px 26px; border: 2px solid #0f766e; border-radius: 10px; background: transparent; color: #0f766e; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; transition: color .3s; }
.bh1::before { content: ""; position: absolute; inset: 0; z-index: -1; background: #0f766e; transform: scaleY(0); transform-origin: bottom; transition: transform .3s ease; }
.bh1:hover, .bh1:focus-visible { color: #fff; }
.bh1:hover::before, .bh1:focus-visible::before { transform: scaleY(1); }
.bh1:focus-visible { outline: 3px solid #5eead4; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .bh1::before { transition: none; } }

30. Label Slides Out, Icon Slides In

ButtonIcon

On hover the label slides off to the right and an arrow slides in from the left to take its place. Both live in the button the whole time; the arrow is aria-hidden, so the accessible name is always the label text.

View code
<button class="bh2"><span class="l">Next step</span><span class="i" aria-hidden="true">&rarr;</span></button>
.bh2 { position: relative; overflow: hidden; min-width: 150px; padding: 14px 26px; border: 0; border-radius: 999px; background: #e2e8f0; color: #0f172a; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; }
.bh2 span { display: block; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.bh2 .i { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; transform: translateX(-100%); }
.bh2:hover .l, .bh2:focus-visible .l { transform: translateX(150%); }
.bh2:hover .i, .bh2:focus-visible .i { transform: none; }
.bh2:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .bh2 span { transition: none; } }

31. Corner Borders Meet on Hover

ButtonBorder

Two L-shaped borders sit in opposite corners and grow along the edges until they meet, forming a full frame. They are the button's ::before and ::after with only two borders each, and their width and height transition together.

View code
<button class="bh3">View collection</button>
.bh3 { position: relative; padding: 15px 28px; border: 0; background: transparent; color: #f8fafc; font: 700 15px Inter, system-ui, sans-serif; letter-spacing: .04em; cursor: pointer; }
.bh3::before, .bh3::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid #f59e0b; transition: width .35s ease, height .35s ease; }
.bh3::before { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.bh3::after { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.bh3:hover::before, .bh3:hover::after, .bh3:focus-visible::before, .bh3:focus-visible::after { width: calc(100% - 2px); height: calc(100% - 2px); }
.bh3:focus-visible { outline: 2px dashed #fcd34d; outline-offset: 6px; }
@media (prefers-reduced-motion: reduce) { .bh3::before, .bh3::after { transition: none; } }

32. Offset Shadow Press

ButtonBrutalist

A bold neo-brutalist button with a hard offset shadow. Hover pulls it further from its shadow and pressing pushes it flat into the shadow, so the button feels physical. The shadow is a box-shadow with no blur.

View code
<button class="bh4">Get the kit</button>
.bh4 { padding: 14px 26px; border: 2px solid #111; border-radius: 8px; background: #a3e635; color: #111; font: 800 16px Inter, system-ui, sans-serif; cursor: pointer; box-shadow: 4px 4px 0 #111; transition: transform .15s, box-shadow .15s; }
.bh4:hover, .bh4:focus-visible { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 #111; }
.bh4:active { transform: translate(4px, 4px); box-shadow: 0 0 0 #111; }
.bh4:focus-visible { outline: 3px solid #2563eb; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .bh4 { transition: none; } }

33. Split Fill from the Middle

ButtonHover

Two halves of colour slide in from both sides and meet in the middle on hover. Each half is a pseudo-element half the button's width, scaled from its own outer edge, which gives a curtain-closing feel.

View code
<button class="bh5">Start building</button>
.bh5 { position: relative; isolation: isolate; overflow: hidden; padding: 14px 28px; border: 2px solid #a78bfa; border-radius: 10px; background: transparent; color: #ddd6fe; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; transition: color .3s; }
.bh5::before, .bh5::after { content: ""; position: absolute; top: 0; bottom: 0; width: 51%; z-index: -1; background: #7c3aed; transform: scaleX(0); transition: transform .3s ease; }
.bh5::before { left: 0; transform-origin: left; } .bh5::after { right: 0; transform-origin: right; }
.bh5:hover, .bh5:focus-visible { color: #fff; }
.bh5:hover::before, .bh5:hover::after, .bh5:focus-visible::before, .bh5:focus-visible::after { transform: scaleX(1); }
.bh5:focus-visible { outline: 3px solid #c4b5fd; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .bh5::before, .bh5::after { transition: none; } }

34. Magnetic Button

ButtonJavaScript

The button leans toward the pointer as it approaches and springs back when it leaves, a playful effect for one hero action. Script moves it a fraction of the pointer's distance from its centre with transform, and does nothing when reduced motion is set.

View code
<div class="bh6"><button>Let’s talk</button></div>
.bh6 { display: grid; place-items: center; width: 260px; max-width: 100%; height: 160px; }
.bh6 button { padding: 18px 32px; border: 0; border-radius: 999px; background: #101828; color: #fff; font: 700 16px Inter, system-ui, sans-serif; cursor: pointer; transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.bh6 button:focus-visible { outline: 3px solid #84adff; outline-offset: 3px; }
var area = document.querySelector('.bh6'), b = area.querySelector('button');
if (!matchMedia('(prefers-reduced-motion: reduce)').matches) {
  area.addEventListener('pointermove', function (e) { var r = b.getBoundingClientRect(), x = e.clientX - (r.left + r.width / 2), y = e.clientY - (r.top + r.height / 2); b.style.transform = 'translate(' + x * .25 + 'px,' + y * .35 + 'px)'; });
  area.addEventListener('pointerleave', function () { b.style.transform = ''; });
}

35. Diagonal Skewed Fill

ButtonHover

A slanted block of colour slides across the button from the left, with its leading edge angled by skewX. The block starts outside the button, wider than it so the slant never leaves a gap, and overflow: hidden trims it to the rounded shape.

View code
<button class="bh7">Watch the film</button>
.bh7 { position: relative; isolation: isolate; overflow: hidden; padding: 14px 28px; border: 2px solid #f43f5e; border-radius: 6px; background: transparent; color: #fecdd3; font: 700 15px Inter, system-ui, sans-serif; cursor: pointer; transition: color .35s; }
.bh7::before { content: ""; position: absolute; top: 0; bottom: 0; left: -20%; width: 140%; z-index: -1; background: #e11d48; transform: translateX(-100%) skewX(-25deg); transition: transform .4s cubic-bezier(.7,0,.3,1); }
.bh7:hover, .bh7:focus-visible { color: #fff; }
.bh7:hover::before, .bh7:focus-visible::before { transform: translateX(0) skewX(-25deg); }
.bh7:focus-visible { outline: 3px solid #fda4af; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .bh7::before { transition: none; } }

About these CSS Hover Effects

Hover is a hint, not a requirement

Touch screens have no hover, so nothing important may depend on it. Actions that appear on hover must be visible on touch devices (@media (hover: none)) and reachable with the keyboard.

Mirror hover on focus

Copy each :hover rule to :focus-visible, or to :focus-within for containers, so keyboard users get the same feedback.

:has() for group effects

Effects that change the neighbours, like dimming the other links, need the parent to know a child is hovered. .nav:has(a:hover) a:not(:hover) does it without script.

Fast in, fast out

Interface hovers should respond in 150 to 300ms. Longer transitions make a page feel sluggish when the pointer moves across many items.

Frequently asked questions

How is this different from the button and card hover pages?

Those focus on one component; these are general patterns for lists, navs, tiles and icons.

Do hover effects affect performance?

Transform, opacity and colour changes are cheap. Avoid hovers that change layout sizes on large lists.

Should I disable hover effects for reduced motion?

Remove the movement; colour and opacity changes can stay.