<div class="container">
<a href="#" class="btn btn--gradient">Fixed-width Background Gradients</a>
<a href="#" class="btn btn--gradient">Button #2</a>
<a href="#" class="btn btn--gradient">Super long button with more copy than you ever expected to have</a>
<p class="description">For when you want consistently-sized background gradients but your buttons are all different sizes.</p>
<p class="description"><strong>Note:</strong> Falls back to default color for legacy browsers.</p>
</div>
// --------------------------------
// Fixed-width Background Gradients
// --------------------------------
/* Structure */
.btn {
display: inline-block;
padding: 1em 2em;
overflow: hidden;
border-radius: 6px;
background: #822a76;
color: #fff;
line-height: 1;
text-decoration: none;
}
/* Skin */
// Pseudo-free version (thanks, @joeyhoer!)
// http://caniuse.com/#search=calc
.btn--gradient {
$color-start : #822a76;
$color-end : #e82d6b;
$gradient-width : 200px;
background-color: $color-end;
background-image: linear-gradient(
to right,
$color-start calc(50% - #{$gradient-width / 2}),
$color-end calc(50% + #{$gradient-width / 2})
);
}
// --------------------------------
// Decorations
// --------------------------------
html {
font-family: sans-serif;
line-height: 1.5;
}
body {
margin: 0;
}
@media (min-height: 440px) {
html,
body,
.container {
height: 100%;
}
}
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
background-image: radial-gradient(farthest-corner at center, #fff 20%, #ccc);
}
.container a {
margin-bottom: 1em;
}
.description {
max-width: 25em;
text-align: center;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.