[ng-alain系列]工具类规则

news/2024/7/1 9:59:47

工具类规则

ng-alain 在 Ant Design 的基础上生产一套尺寸、间距、颜色等工具类。

尺寸

我认为这些工具类只会运用在内容区域,因此,按 Ant Design 的规范,尺寸的宽度是以一个 8px Gutter 基础间距为基础;并衍生出三个尺寸,分别为:

名称公式尺寸说明
sm$gutter8px小号
md$gutter * 216px中号
lg$gutter * 324px大号

依这些尺寸规则,衍生出尺寸微调整的类,这些类包括 marginpadding,其命名规则如下。

类型包括:paddingmargin

方向包括:toprightbottomleftxleftright)、ytopbottom);方向为可选。

消除

[<类型>p|m][<方向>t|r|b|l|x|y]?0

基础

[<类型>p|m][<方向>t|r|b|l|x|y]?-[<尺寸>sm|md|lg]

示例:

.p-sm { padding: 8px !important; }
.pt-sm { padding-top: 8px !important; }
.m-sm { margin: 16px !important; }
.mt-md { margin-top: 16px !important; }

.p0 { padding: 0 !important; }

色彩

Ant Design 并没有按钮色这一说,而是以视觉效果为基准。nz-button 包括四种类型:primarydashed 等。但 primary 是固定的蓝色系列,这是默认色系。

ng-alain 依然不会破坏这种规则,但依 色彩 章节,我产生了一种运用于文本、背景的色系类。

色彩一共有十种,前九种依色彩为准,以及新增一种 teal【#20c997】 (别问我为什么,我就喜欢偶数而已),分别如下:

名称基本色说明
red#f04134热情、警示
green#00a854成功、通过、安全
blue#108ee9专业、科技
pink#f5317f典雅、明快、女性
orange#f56a00醒目、温暖
purple#7265e6高雅、浪漫
yellow#ffbf00活力、提示
cyan#00a2ae清新、冷静、结构化
grey#bfbfbf平稳、中性
teal#20c997

这些色彩会衍生出 10 种渐变色,然而每一种渐变色要想产生一个有效的命名(10 * 10)非常困难。因此,我只衍生三种颜色规则,分别为:

名称色号
light5号
normal6号
dark7号

然后依以下规则产生:

类型包括:textbackground-colorbackground-color:hover

[<类型>text|bg]-[<色彩名>red|green|blue|pink|orange|purple|yellow|cyan|teal|grey](-[light|dark])?(-h)?

normal 本身即是基本色,所以实际无须加上 normal

grey 可能会更常用,因此,除了 grey-lightgrey-dark 额外增加了 grey-lightergrey-darker 表示更浅深度。

示例:

// Text color
.text-red-light { color: #fabeb9 !important; }
.text-red { color: #f04134 !important; }
.text-red-dark { color: #a31837 !important; }

// background-color color
.bg-red-light { background-color: #fabeb9 !important; }
.bg-red { background-color: #f04134 !important; }
.bg-red-dark { background-color: #a31837 !important; }

// hover color
.bg-red-light-h { &:hover { background-color: #fabeb9 !important; } }
.bg-red-h { &:hover { background-color: #f04134 !important; } }
.bg-red-dark-h { &:hover { background-color: #a31837 !important; } }

别名

实际上 Ant Design 提供一套类似 bootstrap 的命名方式的别名规则。只是,我们无法使用到这里内置的而已,这些别名包括:

别名色系
primaryblue
successgreen
errorred
warningyellow

进而,我将取转化成文本与背景,其命名规则同上面一样,只是将色彩名变成为别名而已。

示例:

// Text color
.text-error-light { color: #fabeb9 !important; }
.text-error { color: #f04134 !important; }
.text-error-dark { color: #a31837 !important; }

// background-color color
.bg-error-light { background-color: #fabeb9 !important; }
.bg-error { background-color: #f04134 !important; }
.bg-error-dark { background-color: #a31837 !important; }

// hover color
.bg-error-light-h { &:hover { background-color: #fabeb9 !important; } }
.bg-error-h { &:hover { background-color: #f04134 !important; } }
.bg-error-dark-h { &:hover { background-color: #a31837 !important; } }

Clearfix

ng-zoroo-antd 自带清除浮动 .clearfix

Display

别名CSS
d-nonedisplay: none
d-blockdisplay: block
d-inline-blockdisplay: inline-block
d-flexdisplay: flex
d-inline-flexdisplay: inline-flex

Float

名称说明
fixed-top顶部
fixed-bottom底部

Text

Sizing

Ant Design 是以 12px 为基准字号。

名称说明
text-sm12px
text-md24px
text-lg36px

Alignment

名称说明
text-left文本居左
text-center文本居中
text-right文本居右

Wrapping

**容器必须是 display: inline-blockdisplay: block

名称说明
text-nowrap文本超出不换行
text-truncate文本超出截取并加 ...

Transformation

名称说明
text-lowercase小写文本
text-uppercase大写文本
text-capitalize首词大写
text-deleted删除线

Weight and italics

名称说明
font-weight-normalfont-weight: normal
font-weight-boldfont-weight: 700
font-italicfont-style: italic

Borders

边框

名称说明
borderborder: 1px solid #f5f5f5 !important;
border-0border: 0 !important;
border-top-0border-top: 0 !important;
border-right-0border-right: 0 !important;
border-bottom-0border-bottom: 0 !important;
border-left-0border-left: 0 !important;

颜色

支持色彩章节所有的色系&别名写法,例如:border-redborder-success

圆角

名称说明
rounded-0border-radius: 0;
rounded-circleborder-radius: 50%;
rounded-smborder-radius: 2px;
rounded-mdborder-radius: 4px;
rounded-lgborder-radius: 6px;

Width

名称说明
width-sm160px
width-md240px
width-lg320px

Responsive

类似 Bootstrap 响应式规则,当屏幕小于 480px 时会隐藏所有 hidden-xs 类。

名称屏幕
hidden-xs<480px
hidden-sm<768px
hidden-md<992px
hidden-lg<1200px

Other

名称说明
block-centermargin: 0 auto
pointcursor: pointer
no-resize设置不允许调整元素

http://www.niftyadmin.cn/n/2249233.html

相关文章

利用链表求集合的差集

内容&#xff1a;如果以单链表表示集合&#xff0c;假设集合A用单链表LA表示&#xff0c;集合B用单链表LB表示&#xff0c;设计算法求两集合的差&#xff0c;即A-B。用C语言实现程序解决问题。 算法分析&#xff1a;由集合运算的规则可知&#xff0c;集合的差A-B中包含所有属于…

numpy nan的判定 和 处理

目录np.nan的判定np.nan处理 将当前列的nan位置用平均数进行代替jupyter notebook源码np.nan的判定 np.nan处理 将当前列的nan位置用平均数进行代替 jupyter notebook 源码 def fill_ndarray(t1):for i in range(t1.shape[1]): # 遍历每一列temp_col t1[:, i] # 当前的一列…

代码质量优先——《编写高质量代码:改善c程序代码的125个建议》

高质量的代码不但可以促进团队合作、减少bug处理、降低维护成本&#xff0c;对程序员自身的成长也是至关重要的。很难想象一个参考《如何编写无法维护的代码》写代码的程序员技术成长的上限有多么低。为了写出高质量的代码&#xff0c;我们需要听取过来人的改善代码质量的经验&…

顺序表的逆置

1.内容: 用顺序表作为存储结构&#xff0c;实现将线性表就地逆置的操作&#xff0c;所谓“就地”&#xff0c;指辅助空间应为O(1)。 2.算法分析 利用顺序表实现线性表就地逆置操作&#xff0c;其基本思想为将顺序表的第一个元素与最后一个元素进行互换&#xff0c;将第二个元…

小巧的HTTP Server[C语言]

2019独角兽企业重金招聘Python工程师标准>>> 六款小巧的HTTP Server[C语言] 1、micro_httpd - really small HTTP server 特点&#xff1a; 支持安全的 .. 上级目录过滤 支持通用的MIME类型 支持简单的目录 支持目录列表 支持使用 index.html 作…

有技术也有趋势,2017百度云智峰会免费参会邀约

9 月 2 日&#xff0c;期待已久的第二届百度云智峰会即将开幕&#xff0c;本届峰会依然以人工智能、大数据和云计算为主旋律。不过&#xff0c;不同于往届概念性的阐述和展望&#xff0c;今年峰会似乎更加注重“实践”与“融合”&#xff0c;大会着力强调“Innovation”&#x…

线性链表的分割

1.内容:已知一个线性链表表示的线性表中含有三类字符的数据元素&#xff08;如字母字符&#xff0c;数字字符和其它字符&#xff09;&#xff0c;试编写算法将该线性链表分割为三个循环链表&#xff0c;其中每个循环链表表示的线性表中均只含有一类字符。 2.算法分析 首先建立…

十进制整数转换为任意进制数

内容: 将十进制整数num转换为r进制数&#xff0c;其转换方法为辗转相除法。要求用链栈实现。 步骤&#xff1a; 算法分析 本题需要将十进制整数num转换为任意进制数&#xff0c;要求使用链栈实现转换。程序中设计了四个函数&#xff0c;(1)函数InitStack()用来初始化一个顺序…