Skip to content

Instantly share code, notes, and snippets.

@kodie
Last active April 23, 2021 18:15
Show Gist options
  • Save kodie/9a275b330c49225d83923a42962d4e43 to your computer and use it in GitHub Desktop.
Save kodie/9a275b330c49225d83923a42962d4e43 to your computer and use it in GitHub Desktop.
fancy-bottom-border SCSS mixin
@mixin fancy-bottom-border($border-color: 'blue', $border-size: 4px, $line-height: 1rem) {
$bg-stop: calc(#{$line-height} - #{$border-size});
background-image: linear-gradient(to bottom, transparent $bg-stop, $border-color $bg-stop, $border-color $line-height);
background-repeat: repeat-y;
background-size: 100% $line-height;
line-height: $line-height;
text-decoration: none;
}
body, a {
color: #3F4444;
font-size: 2rem;
}
a {
@include fancy-bottom-border(#F2CD00, 6px, 2rem);
}
<p>Here is some text and we're going to show you a long link that will wrap... <a href="#">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</a> See how the border wraps with the text?</p>
body, a {
color: #3F4444;
font-size: 2rem;
}
a {
background-image: linear-gradient(to bottom, transparent calc(2rem - 6px), #F2CD00 calc(2rem - 6px), #F2CD00 2rem);
background-repeat: repeat-y;
background-size: 100% 2rem;
line-height: 2rem;
text-decoration: none;
}
{
"sass": {
"compiler": "dart-sass/1.26.11",
"extensions": {},
"syntax": "SCSS",
"outputStyle": "expanded"
},
"autoprefixer": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment