【scss】样式用法

文章详细介绍了Sass变量和一系列混合器的使用,如flex布局、过渡效果、滚动条样式以及文本省略处理,展示了如何在index.scss中导入并应用var.scss中的内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

var.scss 公共scss

@use "sass:math";
$base_vm: 1920;

@function vm($px) {
    @return $px * 1px;
}

@mixin flex {
    display: flex;
    justify-content: center;
    align-items: center;
}

@mixin flex-start {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

@mixin flex-start-wrap {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
}

@mixin flex-end {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

@mixin flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

@mixin flex-stretch {
    display: flex;
    justify-content: stretch;
    align-items: center;
}

@mixin flex-col {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

@mixin flex-col-start {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-direction: column;
}

@mixin flex-col-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: column;
}

@mixin hover-highlight {
    transition: filter 0.25s ease-in-out;

    &:hover {
        filter: brightness(1.15);
    }
}

@mixin scroll {
    &::-webkit-scrollbar {
        width: vm(8);
    }

    &::-webkit-scrollbar-thumb {
        border-radius: 999px;
        background: rgb(white, 0.25);
    }

    &::-webkit-scrollbar-track {
        border-radius: 999px;
        background: transparent;
        box-shadow: none;
    }
}

@mixin scroll-hover {
    &::-webkit-scrollbar {
        width: vm(7);
        height: vm(7);
    }


    &::-webkit-scrollbar-thumb {
        border-radius: 999px;
        background: rgba(255, 255, 255, 0);
    }

    &::-webkit-scrollbar-track {
        border-radius: 999px;
        background: transparent;
        box-shadow: none;
    }

    &::-webkit-scrollbar-corner {
        background: transparent;
    }

    &:hover {
        &::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.5);
        }
    }
}

@mixin ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

$standard: #00D92E;
$unstandard: #FFCC00;
$null: #6b6b6b;

$smallWidgetW: vm(333);
$smallWidgetH: vm(130);
$smallMiddleWidgetW: vm(333);
$smallMiddleWidgetH: vm(217);
$longWidgetW: vm(686);
$longWidgetH: vm(130);
$middleWidgetW: vm(686);
$middleWidgetH: vm(197);
$bigWidgetW: vm(686);
$bigWidgetH: vm(242);
$largeWidgetW: vm(686);
$largeWidgetH: vm(310);
$hugeWidgetW: vm(686);
$hugeWidgetH: vm(403);
$widgetSizeMap: (
    small: $smallWidgetW $smallWidgetH vm(10),
    smallMiddle: $smallMiddleWidgetW $smallMiddleWidgetH vm(10),
    long: $longWidgetW $longWidgetH vm(10),
    middle: $middleWidgetW $middleWidgetH vm(4),
    big: $bigWidgetW $bigWidgetH vm(10),
    large: $largeWidgetW $largeWidgetH vm(10),
    huge: $hugeWidgetW $hugeWidgetH vm(10),
    )

$steps: 50-1;

@keyframes loading_gif {
    @for $i from 1 through $steps {
        #{ math.div(100,$steps)*$i * 1%} {
            background-position: 0 vm(-120)*$i;
        }
    }
}

scss文件的使用
index.scss

@import 'styles/var.scss';   //var.scss文件的导入 
div { 
       @include flex-col-start; // 使用var.scss文件里面的flex-col-start
}

:deep 用法

:deep(.el-step__main) {
  position: relative;
  top: -40px;
  left: 35px;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

*阿漓*

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值