07Grid span expand on hover
grid-column: span itself never transitions, so the expand-on-hover effect is faked with transform: scale plus a raised z-index overlapping the neighboring cell instead.
Best forDashboards or catalog grids where one cell needs a temporary enlarged focus
scalez-indextransform-origin: top left

<main class="stage">
<div class="he-grid is-demo">
<div class="he-tile he-focal">
<span class="he-tile__tag">Live</span>
<span class="he-tile__num">128</span>
</div>
<div class="he-tile">
<span class="he-tile__tag">Users</span>
</div>
<div class="he-tile">
<span class="he-tile__tag">Sessions</span>
</div>
<div class="he-tile">
<span class="he-tile__tag">Errors</span>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-enter;
$easing: $ease-spring;
$scale: 1.35;
@include stage($stage-orange);
.he-grid {
width: min(320px, 88vw);
aspect-ratio: 340 / 190;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: $sp-2;
}
.he-tile {
border-radius: $r-sm;
padding: $sp-3;
box-sizing: border-box;
color: $subject-cream;
background: rgba(23, 20, 26, .55);
font: 600 12px/1 -apple-system, "Segoe UI", sans-serif;
display: flex;
flex-direction: column;
justify-content: flex-end;
position: relative;
transform-origin: top left; // 규칙8: 그리드 좌상단 칸 안쪽 확장
}
.he-focal { background: $subject-ink; }
.he-tile__tag { opacity: .8; }
.he-tile__num { font-size: 24px; font-weight: 700; margin-top: $sp-1; }
// grid-column/row 의 span 값 자체는 트랜지션이 걸리지 않는다(이산값이라 중간 프레임이 없다) —
// 그래서 실제 칸 배치는 그대로 두고 transform: scale + z-index 로 옆 칸을 덮어 "확장"을 흉내 낸다
.he-focal {
transition: transform $duration $easing, box-shadow $duration $easing;
box-shadow: $shadow-press;
}
.he-focal:hover {
transform: scale($scale);
box-shadow: $shadow-raised;
z-index: 5;
}
@keyframes he-expand {
0%, 100% { transform: scale(1); box-shadow: $shadow-press; z-index: 1; }
50% { transform: scale($scale); box-shadow: $shadow-raised; z-index: 5; }
}
.he-grid.is-demo .he-focal { animation: he-expand $duration $easing infinite; }
@media (prefers-reduced-motion: reduce) {
.he-focal:hover,
.he-grid.is-demo .he-focal { animation: none !important; transform: none !important; box-shadow: $shadow-press !important; z-index: 1 !important; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ff4d1f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.he-grid {
width: min(320px, 88vw);
aspect-ratio: 340/190;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 8px;
}
.he-tile {
border-radius: 8px;
padding: 12px;
box-sizing: border-box;
color: #fff7e6;
background: rgba(23, 20, 26, 0.55);
font: 600 12px/1 -apple-system, "Segoe UI", sans-serif;
display: flex;
flex-direction: column;
justify-content: flex-end;
position: relative;
transform-origin: top left;
}
.he-focal {
background: #17141a;
}
.he-tile__tag {
opacity: 0.8;
}
.he-tile__num {
font-size: 24px;
font-weight: 700;
margin-top: 4px;
}
.he-focal {
transition: transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
}
.he-focal:hover {
transform: scale(1.35);
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
z-index: 5;
}
@keyframes he-expand {
0%, 100% {
transform: scale(1);
box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
z-index: 1;
}
50% {
transform: scale(1.35);
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
z-index: 5;
}
}
.he-grid.is-demo .he-focal {
animation: he-expand 600ms cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@media (prefers-reduced-motion: reduce) {
.he-focal:hover,
.he-grid.is-demo .he-focal {
animation: none !important;
transform: none !important;
box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32) !important;
z-index: 1 !important;
}
}import { CSSProperties } from "react";
import styles from "./HoverExpandSpan.module.scss";
type Vars = CSSProperties & {
"--duration"?: string;
"--easing"?: string;
"--scale"?: number;
};
export interface HoverExpandSpanProps {
duration?: string;
easing?: string;
scale?: number;
}
// grid-column/row 의 span 값은 트랜지션이 걸리지 않아 transform: scale + z-index 로 확장을 흉내 낸다
export default function HoverExpandSpan({
duration = "600ms",
easing = "cubic-bezier(.2, .8, .2, 1)",
scale = 1.35,
}: HoverExpandSpanProps) {
const style: Vars = {
"--duration": duration,
"--easing": easing,
"--scale": scale,
};
return (
<div className={styles.grid} style={style}>
<div className={`${styles.tile} ${styles.focal}`}>
<span className={styles.tag}>Live</span>
<span className={styles.num}>128</span>
</div>
<div className={styles.tile}>
<span className={styles.tag}>Users</span>
</div>
<div className={styles.tile}>
<span className={styles.tag}>Sessions</span>
</div>
<div className={styles.tile}>
<span className={styles.tag}>Errors</span>
</div>
</div>
);
}07 Grid span expand on hover — Measured area 13.703% · moving frames 23/23Original by GODRICH · SCSS and React ship in the zip · 9 CSS Bento Grid Hover Animations to Copy-Paste
The post this demo lives in
9 CSS Bento Grid Hover Animations to Copy-PasteA bento grid is a layout built from big and small boxes fitted together like a photo collage, the shape you see on portf See all demos in this post


