Underline SASS mixin

In this example below you will see how to do a Underline SASS mixin with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by moritzjacobs, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright moritzjacobs ©
  • HTML
  • CSS
  • JavaScript
    <p>Hallo, <u>ich bin unterstrichen, da sind geile Unterlängen drin. Bitch</u>.</p>

/*Downloaded from https://www.codeseek.co/moritzjacobs/underline-sass-mixin-bVaWyM */
    body {
	font-size: 2em;
	font-family: Courier;
	padding: 50px;
	// background-color: yellow;
}

@mixin smart-underline($background: #fff, $text: #000, $selection: #ffc, $position: 89%, $width:0.03em){

	color: inherit;
	text-decoration: none;
	background:
		linear-gradient($background, $background),
		linear-gradient($background, $background),
		linear-gradient($text, $text);
	background-size: .05em $width, .05em $width, $width $width;
	background-repeat: no-repeat, no-repeat, repeat-x;
	text-shadow: 0.03em 0 $background, -0.03em 0 $background, 0 0.03em $background, 0 -0.03em $background, 0.06em 0 $background, -0.06em 0 $background, 0.09em 0 $background, -0.09em 0 $background, 0.12em 0 $background, -0.12em 0 $background, 0.15em 0 $background, -0.15em 0 $background;
	background-position: 0 $position, 100% $position;

	&::selection {
		text-shadow: 0.03em 0 $selection, -0.03em 0 $selection, 0 0.03em $selection, 0 -0.03em $selection, 0.06em 0 $selection, -0.06em 0 $selection, 0.09em 0 $selection, -0.09em 0 $selection, 0.12em 0 $selection, -0.12em 0 $selection, 0.15em 0 $selection, -0.15em 0 $selection;
		background: $selection;
	}
	
	&:before, &:after, *, *:before, *:after {
		text-shadow: none;
	}
	&:visited{
		color: inherit;
	}

}

u {
	@include smart-underline(white, #000, #ffc, 91%, 2px);
	// @include smart-underline;
}


/*Downloaded from https://www.codeseek.co/moritzjacobs/underline-sass-mixin-bVaWyM */
    

Comments