File tree 2 files changed +12
-8
lines changed
2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1
1
@charset " utf-8" ;
2
2
3
+ @use " sass:math" ;
4
+
3
5
/// /
4
6
/// 辅助数值计算的工具方法
5
7
/// @author Kayo
91
93
/// @param {Number | String} $parent - 较大的长度值
92
94
/// @param {Number | String} $child - 较小的长度值
93
95
@function getLengthMaxIntegerCenter ($parent , $child ) {
94
- $center : ($parent - $child ) / 2 ;
96
+ $center : math . div ($parent - $child , 2 ) ;
95
97
// 注意这里的取整使用 ceil 而不是 floor 并不是随意写的,这是模拟现代浏览器对于小数点长度值的表现而定的。
96
98
// 例如,margin-top: 10.5px 在现代浏览器中会表现为 margin-top: 11px 而不是 margin-top: 10px
97
99
// 又例如,margin-top: -10.5px 在现代浏览器的表现等同于 margin-top: -10px 而不是 margin-top: -11px
130
132
@function sqrt ($num ) {
131
133
$temp :1 ;
132
134
@while abs ($temp - $num / $temp ) > 1e-6 {
133
- $temp : ($temp + $num / $temp ) / 2 ;
135
+ $temp : ($temp + $num / $temp ) / 2 ;
134
136
}
135
137
@return $temp ;
136
138
}
Original file line number Diff line number Diff line change 1
1
@charset " utf-8" ;
2
2
3
+ @use " sass:math" ;
4
+
3
5
/// /
4
6
/// 辅助编写样式效果的工具方法
5
7
/// @author Kayo
25
27
position : absolute ;
26
28
left : 50% ;
27
29
top : 50% ;
28
- margin : (- $height ) / 2 0 0 (- $width ) / 2 ;
30
+ margin : math . div (- $height , 2 ) 0 0 math . div (- $width , 2 ) ;
29
31
}
30
32
31
33
%triangleCommonStyle {
50
52
@extend %triangleCommonStyle ;
51
53
/* 向上小三角 */
52
54
@if $direction == top {
53
- border-width : $height $width / 2 ;
55
+ border-width : $height math . div ( $width , 2 ) ;
54
56
border-top : 0 ;
55
57
border-bottom-color : $borderColor ;
56
58
}
57
59
/* 向下小三角 */
58
60
@else if $direction == bottom {
59
- border-width : $height $width / 2 ;
61
+ border-width : $height math . div ( $width , 2 ) ;
60
62
border-bottom : 0 ;
61
63
border-top-color : $borderColor ;
62
64
}
63
65
/* 向左小三角 */
64
66
@else if $direction == left {
65
- border-width : $width / 2 $height ;
67
+ border-width : math . div ( $width , 2 ) $height ;
66
68
border-left : 0 ;
67
69
border-right-color : $borderColor ;
68
70
}
69
71
/* 向右小三角 */
70
72
@else if $direction == right {
71
- border-width : $width / 2 $height ;
73
+ border-width : math . div ( $width , 2 ) $height ;
72
74
border-right : 0 ;
73
75
border-left-color : $borderColor ;
74
76
}
183
185
}
184
186
height : 300% ;
185
187
border-radius : $borderRadius * 3 ;
186
- transform : scale (( 1 / 3 ));
188
+ transform : scale (math . div ( 1 , 3 ));
187
189
}
188
190
}
189
191
}
You can’t perform that action at this time.
0 commit comments