linear-gradient的mixin
来源:互联网 发布:莫知我哀全文 编辑:程序博客网 时间:2024/04/28 18:21
转载至https://www.sitepoint.com/building-linear-gradient-mixin-sass/
@function legacy-direction($value) { @if is-direction($value) == false { @error "Cannot convert '#{$value}' to legacy syntax because it doesn't seem to be a direction."; } $conversion-map: ( to top : bottom, to top right : bottom left, to right top : left bottom, to right : left, to bottom right : top left, to right bottom : left top, to bottom : top, to bottom left : top right, to left bottom : right top, to left : right, to left top : right bottom, to top left : bottom right ); @if map-has-key($conversion-map, $value) { @return map-get($conversion-map, $value); } @return 90deg - $value;}@mixin linear-gradient($direction, $color-stops...) { @if is-direction($direction) == false { $color-stops: $direction, $color-stops; $direction: 180deg; } background: nth(nth($color-stops, 1), 1); background: -webkit-linear-gradient(legacy-direction($direction), $color-stops); background: linear-gradient($direction, $color-stops);}@function is-direction($value) { $is-keyword: index((to top, to top right, to right top, to right, to bottom right, to right bottom, to bottom, to bottom left, to left bottom, to left, to left top, to top left), $value); $is-angle: type-of($value) == 'number' and index('deg' 'grad' 'turn' 'rad', unit($value)); @return $is-keyword or $is-angle;}
使用:
.selector-1 { @include linear-gradient(#31B7D7, #EDAC7D);}.selector-2 { @include linear-gradient(to right, #E47D7D 0%, #C195D3 50%, #4FB4E8 100%);}.selector-3 { @include linear-gradient(42deg, #B58234 0%, #D2B545 50%, #D7C04D 50.01%, #FFFFFF 100%);}
得到css
0 0
- linear-gradient的mixin
- css3 linear-gradient的使用
- linear-gradient
- linear-gradient
- linear-gradient()
- CSS3样式linear-gradient的使用
- CSS3的线性渐变(linear-gradient)
- 纯css3实现斑马线repeating-linear-gradient和linear-gradient的妙用
- linear-gradient与radial-gradient
- linear conjugate gradient method
- -linear-gradient()线性渐变
- linear-gradient 渐变
- Svg Linear Gradient
- -webkit-linear-gradient 学习
- linear-gradient用法
- linear-gradient() 实现渐变
- Css3-linear-gradient属性
- CSS3 背景渐变色 linear-gradient的兼容问题
- C#-记事本的代码
- javascript 正则匹配url的域名、文件名字
- CI框架源码完全分析之核心文件(输入类)Input.php
- SpringMVC Controller异常拦截@ControllerAdvice
- C#编程中代码实现程序调试的中断触发
- linear-gradient的mixin
- Guava —— Optional
- 文字滚动
- Parajumpers Jacke a side to begin with
- Winfrom DateTimePicker控件 Custom时间格式修改小技巧
- 25、Java入门—多线程之背景知识介绍
- 慕课网-十天精通CSS3-CSS3中的变形与动画(下)
- android使用zxing实现二维码扫描
- 关于mybatis的批量删除操作