TipsBlocks Web Technique Library

PRACTICAL WEB TIP

← Back to library

Segmented Nav Ribbon

A short colored ribbon extends behind the hovered item in a horizontal navigation bar.

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-1080" aria-label="Portfolio categories"><a href="#all">ALL <small>All</small></a><a href="#web">WEB <small>Web design</small></a><a href="#brand">BRAND <small>Brand</small></a></nav>
CSS
.tbx-1080{width:min(300px,100%);background:#f4f2ec;border:1px solid #e2ddd1;display:flex;gap:2px;padding:5px;border-radius:8px;font:700 11px/1.3 system-ui,sans-serif}
.tbx-1080 a{flex:1;min-width:0;position:relative;display:grid;justify-items:center;gap:5px;padding:17px 1px 19px;text-decoration:none;color:#686456;overflow:hidden;transition:background .3s,color .3s;border-radius:5px}
.tbx-1080 a small{font-size:8px;color:#aaa28e;font-weight:600;transition:color .3s;white-space:nowrap}
.tbx-1080 a:before{position:absolute;content:"";left:10px;right:10px;bottom:6px;height:3px;background:#ce8f53;border-radius:9px;transform:scaleX(0) translateX(-12px);transform-origin:left;transition:transform .4s cubic-bezier(.2,1,.3,1)}
.tbx-1080 a:is(:hover,:focus-visible){background:#fff;color:#754f33}.tbx-1080 a:is(:hover,:focus-visible) small{color:#8b7357}.tbx-1080 a:is(:hover,:focus-visible):before{transform:scaleX(1) translateX(0)}
.tbx-1080 a:focus-visible{outline:2px solid #bd895b;outline-offset:2px}
@media(prefers-reduced-motion:reduce){.tbx-1080 *,.tbx-1080 a:before{transition:none!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 portfolio galleries.

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.