mall-app-t/peach/scss/_tools.scss

300 lines
5.4 KiB
SCSS
Raw Normal View History

2024-05-22 15:42:13 +08:00
/* ==================
常用工具
==================== */
.ss-bg-opactity-block {
2024-05-23 01:38:19 +08:00
background-color: rgba(#000, 0.2);
color: #fff;
2024-05-22 15:42:13 +08:00
}
2024-05-23 23:42:33 +08:00
/* ==================
flex gap
==================== */
@for $i from 0 through 100 {
.ss-gap-#{$i} {
gap: $i + rpx;
}
}
2024-05-22 15:42:13 +08:00
/* ==================
flex布局
==================== */
.ss-flex {
2024-05-23 01:38:19 +08:00
display: flex;
flex-direction: row;
align-items: center;
2024-05-22 15:42:13 +08:00
}
.ss-flex-1 {
2024-05-23 01:38:19 +08:00
flex: 1;
2024-05-22 15:42:13 +08:00
}
.ss-flex-col {
2024-05-23 01:38:19 +08:00
display: flex;
flex-direction: column;
2024-05-22 15:42:13 +08:00
}
.ss-flex-wrap {
2024-05-23 01:38:19 +08:00
flex-wrap: wrap;
2024-05-22 15:42:13 +08:00
}
.ss-flex-nowrap {
2024-05-23 01:38:19 +08:00
flex-wrap: nowrap;
2024-05-22 15:42:13 +08:00
}
.ss-col-center {
2024-05-23 01:38:19 +08:00
align-items: center;
2024-05-22 15:42:13 +08:00
}
.ss-col-top {
2024-05-23 01:38:19 +08:00
align-items: flex-start;
2024-05-22 15:42:13 +08:00
}
.ss-col-bottom {
2024-05-23 01:38:19 +08:00
align-items: flex-end;
2024-05-22 15:42:13 +08:00
}
.ss-col-stretch {
2024-05-23 01:38:19 +08:00
align-items: stretch;
2024-05-22 15:42:13 +08:00
}
.ss-row-center {
2024-05-23 01:38:19 +08:00
justify-content: center;
2024-05-22 15:42:13 +08:00
}
.ss-row-left {
2024-05-23 01:38:19 +08:00
justify-content: flex-start;
2024-05-22 15:42:13 +08:00
}
.ss-row-right {
2024-05-23 01:38:19 +08:00
justify-content: flex-end;
2024-05-22 15:42:13 +08:00
}
.ss-row-between {
2024-05-23 01:38:19 +08:00
justify-content: space-between;
2024-05-22 15:42:13 +08:00
}
.ss-row-around {
2024-05-23 01:38:19 +08:00
justify-content: space-around;
2024-05-22 15:42:13 +08:00
}
.ss-self-start {
2024-05-23 01:38:19 +08:00
align-self: flex-start;
2024-05-22 15:42:13 +08:00
}
.ss-self-end {
2024-05-23 01:38:19 +08:00
align-self: flex-end;
2024-05-22 15:42:13 +08:00
}
.ss-self-center {
2024-05-23 01:38:19 +08:00
align-self: center;
2024-05-22 15:42:13 +08:00
}
.ss-h-100 {
2024-05-23 01:38:19 +08:00
height: 100%;
2024-05-22 15:42:13 +08:00
}
.ss-w-100 {
2024-05-23 01:38:19 +08:00
width: 100%;
2024-05-22 15:42:13 +08:00
}
/* ==================
margin padding: 内外边距
==================== */
@for $i from 0 through 100 {
2024-05-23 01:38:19 +08:00
// 只要双数和能被5除尽的数
@if $i % 2==0 or $i % 5==0 {
// 得出u-margin-30或者u-m-30
.ss-margin-#{$i},
.ss-m-#{$i} {
margin: $i + rpx;
2024-05-22 15:42:13 +08:00
}
2024-05-23 01:38:19 +08:00
.ss-m-x-#{$i} {
margin-left: $i + rpx;
margin-right: $i + rpx;
}
.ss-m-y-#{$i} {
margin-top: $i + rpx;
margin-bottom: $i + rpx;
}
// 得出u-padding-30或者u-p-30
.ss-padding-#{$i},
.ss-p-#{$i} {
padding: $i + rpx;
}
.ss-p-x-#{$i} {
padding-left: $i + rpx;
padding-right: $i + rpx;
}
.ss-p-y-#{$i} {
padding-top: $i + rpx;
padding-bottom: $i + rpx;
}
@each $short, $long in l left, t top, r right, b bottom {
// 缩写版,结果如: u-m-l-30
// 定义外边距
.ss-m-#{$short}-#{$i} {
margin-#{$long}: $i + rpx;
}
// 定义内边距
.ss-p-#{$short}-#{$i} {
padding-#{$long}: $i + rpx;
}
// 完整版结果如u-margin-left-30
// 定义外边距
.ss-margin-#{$long}-#{$i} {
margin-#{$long}: $i + rpx;
}
// 定义内边距
.ss-padding-#{$long}-#{$i} {
padding-#{$long}: $i + rpx;
}
}
}
2024-05-22 15:42:13 +08:00
}
/* ==================
radius
==================== */
@for $i from 0 through 100 {
2024-05-23 01:38:19 +08:00
// 只要双数和能被5除尽的数
@if $i % 2==0 or $i % 5==0 {
.ss-radius-#{$i},
.ss-r-#{$i} {
border-radius: $i + rpx;
2024-05-22 15:42:13 +08:00
}
2024-05-23 01:38:19 +08:00
.ss-r-t-#{$i} {
border-top-left-radius: $i + rpx;
border-top-right-radius: $i + rpx;
}
.ss-r-b-#{$i} {
border-bottom-left-radius: $i + rpx;
border-bottom-right-radius: $i + rpx;
}
@each $short, $long in tl "top-left", tr "top-right", bl "bottom-right",
br "bottom-right"
{
// 定义外边距
.ss-r-#{$short}-#{$i} {
border-#{$long}-radius: $i + rpx;
}
// 定义内边距
.ss-radius-#{$long}-#{$i} {
border-#{$long}-radius: $i + rpx;
}
}
}
2024-05-22 15:42:13 +08:00
}
/* ==================
溢出省略号
@param {Number} 行数
==================== */
@mixin ellipsis($rowCount: 1) {
2024-05-23 01:38:19 +08:00
// @if $rowCount <=1 {
// overflow: hidden;
// text-overflow: ellipsis;
// white-space: nowrap;
// } @else {
// min-width: 0;
// overflow: hidden;
// text-overflow: ellipsis;
// display: -webkit-box;
// -webkit-line-clamp: $rowCount;
// -webkit-box-orient: vertical;
// }
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: $rowCount;
-webkit-box-orient: vertical;
2024-05-22 15:42:13 +08:00
}
@for $i from 1 through 6 {
2024-05-23 01:38:19 +08:00
.ss-line-#{$i} {
@include ellipsis($i);
}
2024-05-22 15:42:13 +08:00
}
/* ==================
hover
==================== */
.ss-hover-class {
2024-05-23 01:38:19 +08:00
background-color: $gray-c;
opacity: 0.6;
2024-05-22 15:42:13 +08:00
}
.ss-hover-btn {
2024-05-23 01:38:19 +08:00
transform: translate(1px, 1px);
2024-05-22 15:42:13 +08:00
}
/* ==================
底部安全区域
==================== */
.ss-safe-bottom {
2024-05-23 01:38:19 +08:00
padding-bottom: 0;
padding-bottom: calc(constant(safe-area-inset-bottom) / 5 * 3);
padding-bottom: calc(env(safe-area-inset-bottom) / 5 * 3);
2024-05-22 15:42:13 +08:00
}
/* ==================
字体大小
==================== */
2024-05-23 01:38:19 +08:00
@for $i from 20 through 60 {
.ss-font-#{$i} {
font-size: $i + rpx;
}
2024-05-22 15:42:13 +08:00
}
/* ==================
按钮
==================== */
.ss-reset-button {
2024-05-23 01:38:19 +08:00
padding: 0;
margin: 0;
font-size: inherit;
background-color: transparent;
color: inherit;
position: relative;
border: 0rpx;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
align-items: center;
justify-content: center;
box-sizing: border-box;
text-align: center;
text-decoration: none;
white-space: nowrap;
vertical-align: baseline;
transform: translate(0, 0);
2024-05-22 15:42:13 +08:00
}
.ss-reset-button.button-hover {
2024-05-23 01:38:19 +08:00
transform: translate(1px, 1px);
background: none;
2024-05-22 15:42:13 +08:00
}
.ss-reset-button::after {
2024-05-23 01:38:19 +08:00
border: none;
2024-05-22 15:42:13 +08:00
}