列スポットライト比較表Column Spotlight Table
/* :has() で「触れている列」を丸ごと拾う。物語は3段:
①他の列が沈む ②選んだ列がばねで持ち上がって影が立つ ③見出しの下線が左から伸びる。
th を tabindex で拾えるようにしてあるので、キーボードでも同じ演出になる */
.cg-tb-spot {
border-collapse: separate;
border-spacing: 0;
font-size: 13px;
color: #1B1A17;
font-family: 'Helvetica Neue', Arial, sans-serif;
}
.cg-tb-spot th,
.cg-tb-spot td {
padding: 11px 14px;
background: #fff;
border-bottom: 1px solid #E3DFD4;
text-align: right;
transition: transform .42s cubic-bezier(.34, 1.56, .64, 1), opacity .3s ease, background .3s ease, box-shadow .42s ease;
}
.cg-tb-spot th:first-child,
.cg-tb-spot td:first-child { text-align: left; color: #8A8375; }
.cg-tb-spot thead th {
position: relative;
font-family: 'IBM Plex Mono', monospace;
font-size: 10px;
font-weight: 700;
letter-spacing: .1em;
color: #8A8375;
border-bottom: 2px solid #1B1A17;
outline: none;
}
.cg-tb-spot thead th:focus-visible { outline: 2px solid #3A5A78; outline-offset: -2px; }
/* 見出しの下線: 左から伸びる第3の層 */
.cg-tb-spot thead th::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 3px;
background: #E8590C;
transform: scaleX(0);
transform-origin: 0 50%;
transition: transform .45s cubic-bezier(.34, 1.56, .64, 1) .04s;
}
.cg-tb-spot tbody tr:last-child td { border-bottom: 2px solid #1B1A17; }
/* ①どこかに触れたら、データ列を一段沈める */
.cg-tb-spot:has(tbody td:hover) tbody td:not(:first-child),
.cg-tb-spot:has(thead th:focus-visible) tbody td:not(:first-child) { opacity: .42; }
/* ②選ばれた列だけ戻して持ち上げる */
.cg-tb-spot:has(tr > :nth-child(2):hover) tr > :nth-child(2),
.cg-tb-spot:has(tr > :nth-child(2):focus-visible) tr > :nth-child(2),
.cg-tb-spot:has(tr > :nth-child(3):hover) tr > :nth-child(3),
.cg-tb-spot:has(tr > :nth-child(3):focus-visible) tr > :nth-child(3),
.cg-tb-spot:has(tr > :nth-child(4):hover) tr > :nth-child(4),
.cg-tb-spot:has(tr > :nth-child(4):focus-visible) tr > :nth-child(4) {
opacity: 1;
background: #FFF7F0;
transform: translateY(-4px);
box-shadow: 0 10px 18px -14px rgba(27, 26, 23, .75);
}
/* ③その列の見出しだけ下線を伸ばす */
.cg-tb-spot:has(tr > :nth-child(2):hover) thead th:nth-child(2)::after,
.cg-tb-spot:has(tr > :nth-child(2):focus-visible) thead th:nth-child(2)::after,
.cg-tb-spot:has(tr > :nth-child(3):hover) thead th:nth-child(3)::after,
.cg-tb-spot:has(tr > :nth-child(3):focus-visible) thead th:nth-child(3)::after,
.cg-tb-spot:has(tr > :nth-child(4):hover) thead th:nth-child(4)::after,
.cg-tb-spot:has(tr > :nth-child(4):focus-visible) thead th:nth-child(4)::after {
transform: scaleX(1);
}
@media (prefers-reduced-motion: reduce) {
.cg-tb-spot th,
.cg-tb-spot td,
.cg-tb-spot thead th::after { transition: none; }
/* 静止形: 浮き上がりは捨てるが「どの列を見ているか」は色と下線で残す */
.cg-tb-spot:has(tr > :nth-child(2):hover) tr > :nth-child(2),
.cg-tb-spot:has(tr > :nth-child(2):focus-visible) tr > :nth-child(2),
.cg-tb-spot:has(tr > :nth-child(3):hover) tr > :nth-child(3),
.cg-tb-spot:has(tr > :nth-child(3):focus-visible) tr > :nth-child(3),
.cg-tb-spot:has(tr > :nth-child(4):hover) tr > :nth-child(4),
.cg-tb-spot:has(tr > :nth-child(4):focus-visible) tr > :nth-child(4) { transform: none; }
}
<table class="cg-tb-spot" role="table" aria-label="プラン比較表"><thead><tr><th scope="col">項目</th><th scope="col" tabindex="0">LITE</th><th scope="col" tabindex="0">STANDARD</th><th scope="col" tabindex="0">PRO</th></tr></thead><tbody><tr><td>月額</td><td>980</td><td>2,480</td><td>4,980</td></tr><tr><td>容量</td><td>5GB</td><td>50GB</td><td>500GB</td></tr><tr><td>サポート</td><td>メール</td><td>優先対応</td><td>専任担当</td></tr></tbody></table>