TipsBlocks Web Technique Library

PRACTICAL WEB TIP

← Back to library

Offset Capsule Slider

Two capsule outlines slide in opposite directions to frame a central action button.

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
<a class="tbx-1182" href="#plans"><span class="tbx-1182__ring" aria-hidden="true"></span><span class="tbx-1182__text">Start a project</span><span class="tbx-1182__dot" aria-hidden="true">↗</span></a>
CSS
.tbx-1182{box-sizing:border-box;position:relative;isolation:isolate;width:245px;max-width:100%;height:68px;display:flex;align-items:center;justify-content:space-between;padding:10px 13px 10px 24px;border-radius:999px;background:#262b47;color:white;border:2px solid #262b47;text-decoration:none;font:750 14px system-ui,sans-serif;transition:background .35s,color .35s}.tbx-1182__ring{pointer-events:none;position:absolute;inset:-8px;border-radius:999px;border:2px solid #b2bfda;z-index:-1;transition:transform .42s,opacity .42s}.tbx-1182::after{content:"";pointer-events:none;position:absolute;inset:5px;border:1px dashed #9eadc9;border-radius:999px;transition:transform .42s,opacity .42s}.tbx-1182__text{position:relative;z-index:1}.tbx-1182__dot{width:40px;height:40px;border-radius:50%;background:#f9bd76;color:#262b47;display:grid;place-items:center;font:800 21px system-ui;transition:transform .4s,background .4s}.tbx-1182:is(:hover,:focus-visible){background:#384777}.tbx-1182:is(:hover,:focus-visible) .tbx-1182__ring{transform:translate(-8px,6px)}.tbx-1182:is(:hover,:focus-visible)::after{transform:translate(7px,-5px);opacity:.65}.tbx-1182:is(:hover,:focus-visible) .tbx-1182__dot{transform:rotate(45deg);background:#f7dd94}.tbx-1182:focus-visible{outline:3px solid #e8b77a;outline-offset:9px}
@media (prefers-reduced-motion:reduce) {.tbx-1182,.tbx-1182 *,.tbx-1182::before,.tbx-1182::after,.tbx-1182 *::before,.tbx-1182 *::after{transition-duration:.01ms!important;animation-duration:.01ms!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 calls to action and pricing pages.

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.