1. 前言
- 在实际开发中,我们可以定义一些公共样式在全局使用,此篇文章记录在开发者使用的scss,将会持续更新中……
- 两个比较好用的将sass转化为css的网站
2.定义代码显示的行数,超出使用...代替
@for $i from 1 through 10 {
.text-cut-#{$i} {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: $i;
-webkit-box-orient: vertical;
}
}
3. 设置字体大小的样式
@for $i from 0 to 100 {
.f-s-#{$i} {
font-size: $i + rpx;
}
}
4. 设置边框圆角
@for $i from 0 to 100 {
.u-br-#{$i} {
border-radius: $i + rpx !important;
}
.u-br-t-l-#{$i} {
border-top-left-radius: $i + rpx;
}
.u-br-t-r-#{$i} {
border-top-right-radius: $i + rpx;
}
.u-br-b-l-#{$i} {
border-bottom-left-radius: $i + rpx;
}
.u-br-b-r-#{$i} {
border-bottom-right-radius: $i + rpx;
}
}
5. 定义内外边距
@for $i from 0 through 200 {
@if $i % 2 == 0 or $i % 5 == 0 {
.u-font-#{$i} {
font-size: $i + rpx !important;
}
.u-m-#{$i} {
margin: $i + rpx !important;
}
.u-p-#{$i} {
padding: $i + rpx !important;
}
@each $short, $long in (t top, r right, b bottom, l left) {
.u-m-#{$short}-#{$i} {
margin-#{$long}: $i + rpx !important;
}
.u-p-#{$short}-#{$i} {
padding-#{$long}: $i + rpx !important;
}
}
@each $short, $long, $short1, $long1 in (t top b bottom, l left r right) {
.u-m-#{$short}-#{$short1}-#{$i} {
margin-#{$long}: $i + rpx !important;
margin-#{$long1}: $i + rpx !important;
}
.u-p-#{$short}-#{$short1}-#{$i} {
padding-#{$long}: $i + rpx !important;
padding-#{$long1}: $i + rpx !important;
}
}
}
}
6. 字体粗细程度(2024/05/09更新)
@each $i in 200, 300, 400, 500, 600, 700, 800, 900 {
.u-font-#{$i} {
font-weight: $i;
.u-count-num {
font-weight: $i !important;
}
}
}
7. flex弹性布局(2024/05/09更新)
.flex {
display: flex;
&-column {
flex-direction: column;
}
&-wrap {
flex-wrap: wrap;
}
&-basis-xs {
flex-basis: 20%;
}
&-basis-sm {
flex-basis: 40%;
}
&-basis-df {
flex-basis: 50%;
}
&-basis-lg {
flex-basis: 60%;
}
&-basis-xl {
flex-basis: 80%;
}
}
.align {
&-start {
align-items: flex-start;
}
&-end {
align-items: flex-end;
}
&-center {
align-items: center;
}
&-stretch {
align-items: stretch;
}
}
.self{
&-start {
align-self: flex-start;
}
&-center {
align-self: center;
}
&-end {
align-self: flex-end;
}
&-stretch {
align-self: stretch;
}
}
.justify{
&-start {
justify-content: flex-start;
}
&-end {
justify-content: flex-end;
}
&-center {
justify-content: center;
}
&-between {
justify-content: space-between;
}
&-around {
justify-content: space-around;
}
}