TipsBlocks Web Technique Library

PRACTICAL WEB TIP

← Back to library

Neighbor-Dim Navigation

Neighboring navigation items fade slightly as a rule appears under the active link.

Live Demo

Hover over the element or use Tab to focus.

Source Code

Copy the HTML, CSS or JavaScript you need for your project.

HTML
<nav class="tbx-1213" aria-label="Sample primary navigation"><a href="#tbx-1213-works">WORKS</a><a href="#tbx-1213-about">ABOUT</a><a href="#tbx-1213-notes">NOTES</a><a href="#tbx-1213-contact">CONTACT</a></nav>
CSS
.tbx-1213{box-sizing:border-box}
.tbx-1213{display:flex;align-items:center;justify-content:center;gap:clamp(8px,2.5vw,23px);flex-wrap:wrap;width:100%;min-height:182px;padding:12px;background:#16181b;font-family:Arial,sans-serif}.tbx-1213 *{box-sizing:border-box}.tbx-1213 a{position:relative;padding:11px 1px;text-decoration:none;white-space:nowrap;font-size:clamp(10px,2.4vw,14px);font-weight:800;letter-spacing:.09em;color:#f3f3f2;transition:color .34s,opacity .34s;outline-offset:7px}.tbx-1213 a::after{content:'';position:absolute;left:0;bottom:2px;width:100%;height:2px;background:#f5c66f;transform:scaleX(0);transform-origin:left;transition:transform .38s}.tbx-1213:is(:hover,:focus-within) a:not(:hover):not(:focus-visible){opacity:.28}.tbx-1213 a:is(:hover,:focus-visible)::after{transform:scaleX(1)}.tbx-1213 a:focus-visible{outline:2px solid #f5c66f}
@media (prefers-reduced-motion:reduce){.tbx-1213 *, .tbx-1213 *::before, .tbx-1213 *::after{transition:none !important;animation:none !important;scroll-behavior:auto !important}}

How to Use

Insert the HTML and add the CSS to your stylesheet. Adjust colors and sizes and avoid class conflicts.

Use Case

Useful for navigation menus and header sections.

Technical Notes

Keep controls usable on touch devices. Test keyboard focus and reduced-motion preferences.

Mobile:Ensure the interactive content remains accessible without hover on touch devices.

Browser:Uses modern CSS. Check behavior in the browsers you support.

Reduced Motion:Check that prefers-reduced-motion is respected.