-
Notifications
You must be signed in to change notification settings - Fork 985
/
Copy pathprojection-word-solid-shadow.md
executable file
·62 lines (49 loc) · 1.83 KB
/
projection-word-solid-shadow.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
## 立体文字阴影
CSS 实现立体文字阴影。
### 关键点
+ 立体文字阴影的关键点在于多层 text-shadow 的叠加
+ 这里合理运用了 SASS 函数来自动计算多层 text-shadow 的 CSS 代码
+ 运用了 Sass 的颜色函数,渐进实现层级阴影颜色
- fade-out: 改变颜色的透明度,让颜色更加透明
- desaturate: 改变颜色的饱和度值,让颜色更少的饱和
HTML:
```html
<div>Txt Shadow</div>
<div class="left"> TxT Long Shadow</div>
```
SCSS:
```scss
body {
background: #03a9f4;
}
@function makelongrightshadow($color) {
$val: 0px 0px $color;
@for $i from 1 through 50 {
$color: fade-out(desaturate($color, 1%), .02);
$val: #{$val}, #{$i}px #{$i}px #{$color};
}
@return $val;
}
@function makelongleftshadow($color) {
$val: 0px 0px $color;
@for $i from 1 through 50 {
$color: fade-out(desaturate($color, 1%), .02);
$val: #{$val}, -#{$i}px #{$i}px #{$color};
}
@return $val;
}
div {
text-align: center;
font-size: 20vmin;
line-height: 45vh;
text-shadow: makelongrightshadow(hsla(14, 100%, 30%, 1));
color: hsl(14, 100%, 60%);
}
.left {
text-shadow: makelongleftshadow(hsla(231, 50%, 30%, 1));
color: hsl(231, 50%, 60%);
}
```
效果如下(点击 `HTML/SCSS` 可以对代码进行编辑):
<iframe height='350' scrolling='no' title='立体文字阴影' src='//codepen.io/Chokcoco/embed/JmgNNa/?height=265&theme-id=0&default-tab=result' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'>See the Pen <a href='https://codepen.io/Chokcoco/pen/JmgNNa/'>立体文字阴影</a> by Chokcoco (<a href='https://codepen.io/Chokcoco'>@Chokcoco</a>) on <a href='https://codepen.io'>CodePen</a>.
</iframe>