stylus

css预处理

calc

1
2
3
4
5
6
img{
width:400px;
height:300px;
padding-left: calc(50vw-400/2);
padding-top: calc(50vh-300/2);
}

Stylus

垂直居中元素

1
2
3
4
5
6
7
8
.center
position absolute
left 50%
top 50%
width 400px
height 300px
margin-left -(@width / 2)
margin-top -(@height / 2)

一像素分割线

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
border-1px($color)
position relative
&::after
display block
position absolute
content ''
width 100%
border-bottom 1px solid $color
left 0
bottom 0
border-none()
border none
&::after
border none
@media screen and (min-device-pixel-ratio:3)
.border-1px
&::after
transform scaleY(0.333)

媒体查询采用不同尺寸的图片

1
2
3
4
bg-img($url)
background-image url($url+"@2x.png")
@media screen and (min-device-pixel-ratio:3)
background-image url($url+"@3x.png")

清除浮动

1
2
3
4
5
6
7
8
9
.clearfix
display inline-block
&::after
content ''
height 0
line-height 0
display block
visibility hidden
clear both
1
2
3
4
5
6
7
vendor(prop, args)
-webkit-{prop} args
-moz-{prop} args
{prop} args

border-radius()
vendor('border-radius', arguments)

变量

1
2
3
4
font-size 14px

body
font font-size Arial, sans-seri

本文作者: 孟 虎
本文链接: https://menghu1994.github.io/blog/2023/10/Style/stylus/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!