【Sass】1px分割线 + 缩进分割线

效果图

1. 亮色模式效果

2. 暗色模式效果

设计思路

  1. 配色使用grey
    • 优点:无论在暗色模式还是亮色模式都可以看清楚分割线
  2. 使用after,before 伪元素绘制线条,并压缩线条transform: scaleY(.25)

注意事项

  1. 必须确保父级有宽高
  2. 父级定位必须为position: relative

Sass代码

css 复制代码
// 顶部分割线  
.mini-heriz
    &::after
        position: absolute
        right: 0
        top: 0
        content: ''
        width: 100%
        height: 1px
        transform: scaleY(.25)
        background: grey

// 顶部缩进分割线  
.mini-heriz-inset
    &::after
        @extend .mini-heriz
        width: 90%
        left: 5%

// 底部分割线  
.mini-heriz-bottom
    &::before
        position: absolute
        right: 0
        bottom: 0
        content: ''
        width: 100%
        height: 1px
        transform: scaleY(.25)
        background: grey


// 底部缩进分割线  
.mini-heriz-bottom-inset
    &::before
        @extend .mini-heriz-bottom
        width: 90%
        left: 5%
相关推荐
a1117761 小时前
医院挂号预约系统(开源 Fastapi+vue2)
前端·vue.js·python·html5·fastapi
0思必得01 小时前
[Web自动化] Selenium处理iframe和frame
前端·爬虫·python·selenium·自动化·web自动化
行走的陀螺仪3 小时前
uni-app + Vue3编辑页/新增页面给列表页传参
前端·vue.js·uni-app
We་ct4 小时前
LeetCode 205. 同构字符串:解题思路+代码优化全解析
前端·算法·leetcode·typescript
2301_812731415 小时前
CSS3笔记
前端·笔记·css3
ziblog5 小时前
CSS3白云飘动动画特效
前端·css·css3
越努力越幸运5085 小时前
CSS3学习之网格布局grid
前端·学习·css3
半斤鸡胗5 小时前
css3基础
前端·css
ziblog5 小时前
CSS3创意精美页面过渡动画效果
前端·css·css3
akangznl5 小时前
第四章 初识css3
前端·css·css3·html5