scss 智能下划线Sass Mixin

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss 智能下划线Sass Mixin相关的知识,希望对你有一定的参考价值。

@mixin smart-underline($background: #fff, $text: #000, $selection: #ffc, $position: 86%){
	a {
		color: inherit;
		text-decoration: none;
		background: -webkit-linear-gradient($background, $background), -webkit-linear-gradient($background, $background), -webkit-linear-gradient($text, $text);
		background-size: .05em 1px, .05em 1px, 1px 1px;
		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-y: $position,$position, $position;
		background-position-x: 0%, 100%, 0%;

		&::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;
		}
		&::-moz-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;
		}
	}
}

以上是关于scss 智能下划线Sass Mixin的主要内容,如果未能解决你的问题,请参考以下文章

scss SASS,SCSS,mixin:PX到EM的转换

scss Mixin Media查询段SASS

scss 变换Mixin Sass

scss Flexbox SASS Mixin:全部

scss Flexbox SASS Mixin:10。订购

scss Sass Link mixin