CSS Offset Frame Button
A solid button with an offset outline frame that snaps into place on hover.
HTML
<button class="btn-frame">Read more</button>
CSS
.btn-frame {
position: relative;
padding: 14px 30px;
border: 0;
background: #86198f;
color: #fff;
font: 600 16px/1 system-ui, sans-serif;
cursor: pointer;
}
.btn-frame::after {
content: "";
position: absolute;
inset: 0;
border: 2px solid #86198f;
transform: translate(7px, 7px);
transition: transform 0.2s ease;
pointer-events: none;
}
.btn-frame:hover::after {
transform: translate(0, 0);
}
About this CSS Offset Frame Button
This CSS Offset Frame Button is 23 lines of pure CSS (0.4 KB) with no JavaScript and no dependencies. It uses transitions and transforms. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
The colors in this snippet. Search and replace them to match your brand:
#86198f#fff
How to use this offset frame button
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.btn-frameclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.