跳转到内容

样式属性速查

全部样式属性及其值语法、初值、适用对象、是否继承、影响绘制还是几何,按定义它们的章分组。完整语义与示例见对应条目。

属性 值 初值 适用 继承 影响
:color 颜色字符串或 currentColor nil 所有节点 是 绘制
:font-family 非空字符串或符号 nil 所有节点 是 绘制 + 几何
:font-size 正数 nil 所有节点 是 绘制 + 几何
:font-weight normal、bold、bolder、lighter 或 100–900 normal 所有节点 是 绘制 + 几何
:font-style normal、italic 或 oblique normal 所有节点 是 绘制 + 几何
:text-decoration-line none,或 underline、overline、line-through 的列表 none 所有节点 否 绘制
:text-decoration-color 颜色字符串或 currentColor currentColor 所有节点 否 绘制
:text-decoration-style solid、double、dotted、dashed 或 wavy solid 所有节点 否 绘制
:box-sizing border-box 或 content-box;其他值按 border-box 处理 border-box 所有非 text 节点 否 几何
:width auto、stretch、min-content、max-content、fit-content 或行内轴长度 auto 所有非 text 节点 否 几何
:min-width :width 的关键字或行内轴长度 auto 所有非 text 节点 否 几何
:max-width none,或 :width 的关键字或行内轴长度 none 所有非 text 节点 否 几何
:height auto、stretch、min-content、max-content、fit-content 或块轴长度 auto 所有非 text 节点 否 几何
:min-height :height 的关键字或块轴长度 auto 所有非 text 节点 否 几何
:max-height none,或 :height 的关键字或块轴长度 none 所有非 text 节点 否 几何
:padding 1–4 个边长,或带 :top、:right、:bottom、:left 键的 plist — 所有非 text 节点 否 绘制 + 几何
:padding-inline 1–2 个行内轴长度 — 所有非 text 节点 否 绘制 + 几何
:padding-block 1–2 个块轴长度 — 所有非 text 节点 否 绘制 + 几何
:padding-top 非负块轴长度 (lh 0) 所有非 text 节点 否 绘制 + 几何
:padding-right 非负行内轴长度 (px 0) 所有非 text 节点 否 绘制 + 几何
:padding-bottom 非负块轴长度 (lh 0) 所有非 text 节点 否 绘制 + 几何
:padding-left 非负行内轴长度 (px 0) 所有非 text 节点 否 绘制 + 几何
:padding-block-start 非负块轴长度 (lh 0) 所有非 text 节点 否 绘制 + 几何
:padding-inline-end 非负行内轴长度 (px 0) 所有非 text 节点 否 绘制 + 几何
:padding-block-end 非负块轴长度 (lh 0) 所有非 text 节点 否 绘制 + 几何
:padding-inline-start 非负行内轴长度 (px 0) 所有非 text 节点 否 绘制 + 几何
:margin 1–4 个边长,或带 :top、:right、:bottom、:left 键的 plist — 所有非 text 节点 否 几何
:margin-inline 1–2 个行内轴长度 — 所有非 text 节点 否 几何
:margin-block 1–2 个块轴长度 — 所有非 text 节点 否 几何
:margin-top 非负块轴长度 (lh 0) 所有非 text 节点 否 几何
:margin-right 非负行内轴长度 (px 0) 所有非 text 节点 否 几何
:margin-bottom 非负块轴长度 (lh 0) 所有非 text 节点 否 几何
:margin-left 非负行内轴长度 (px 0) 所有非 text 节点 否 几何
:margin-block-start 非负块轴长度 (lh 0) 所有非 text 节点 否 几何
:margin-inline-end 非负行内轴长度 (px 0) 所有非 text 节点 否 几何
:margin-block-end 非负块轴长度 (lh 0) 所有非 text 节点 否 几何
:margin-inline-start 非负行内轴长度 (px 0) 所有非 text 节点 否 几何
:border 任意顺序的宽度、样式、颜色,或单个值 — 所有非 text 节点 否 绘制 + 几何
:border-top 任意顺序的宽度、样式、颜色,或单个值 — 所有非 text 节点 否 绘制 + 几何
:border-right 任意顺序的宽度、样式、颜色,或单个值 — 所有非 text 节点 否 绘制 + 几何
:border-bottom 任意顺序的宽度、样式、颜色,或单个值 — 所有非 text 节点 否 绘制 + 几何
:border-left 任意顺序的宽度、样式、颜色,或单个值 — 所有非 text 节点 否 绘制 + 几何
:border-width 1–4 个非负描边长度 — 所有非 text 节点 否 绘制 + 几何
:border-style 1–4 个 none 或 solid — 所有非 text 节点 否 绘制 + 几何
:border-color 1–4 个颜色字符串或 currentColor — 所有非 text 节点 否 绘制
:border-top-p t 或 nil — 所有非 text 节点 否 绘制 + 几何
:border-top-width 非负描边长度 (px 0) 所有非 text 节点 否 绘制 + 几何
:border-right-width 非负描边长度 (px 0) 所有非 text 节点 否 绘制 + 几何
:border-bottom-width 非负描边长度 (px 0) 所有非 text 节点 否 绘制 + 几何
:border-left-width 非负描边长度 (px 0) 所有非 text 节点 否 绘制 + 几何
:border-top-style none 或 solid none 所有非 text 节点 否 绘制 + 几何
:border-right-style none 或 solid none 所有非 text 节点 否 绘制 + 几何
:border-bottom-style none 或 solid none 所有非 text 节点 否 绘制 + 几何
:border-left-style none 或 solid none 所有非 text 节点 否 绘制 + 几何
:border-top-color 颜色字符串或 currentColor currentColor 所有非 text 节点 否 绘制
:border-right-color 颜色字符串或 currentColor currentColor 所有非 text 节点 否 绘制
:border-bottom-color 颜色字符串或 currentColor currentColor 所有非 text 节点 否 绘制
:border-left-color 颜色字符串或 currentColor currentColor 所有非 text 节点 否 绘制
:border-radius 非负行内轴长度 (px 0) 所有非 text 节点 否 绘制
:background-color 颜色字符串 nil 所有节点 否 绘制
:backdrop-filter nil 或 (brightness AMOUNT) nil 所有非 text 节点 否 绘制
:visibility visible 或 hidden visible 所有非 text 节点 否 绘制
:item-gap 非负主轴长度 (px 0) row 与 column 否 几何
:cross-align start、center、end 或 stretch stretch row 与 column 否 几何
:flex-direction row、row-reverse、column 或 column-reverse row flex 否 几何
:flex-wrap nowrap、wrap 或 wrap-reverse nowrap flex 否 几何
:flex-flow 任意顺序的一个方向加一个换行关键字 — flex 否 几何
:justify-content normal、start、end、flex-start、flex-end、center、stretch、space-between、space-around 或 space-evenly flex-start flex 与 grid 否 几何
:align-items normal、start、end、stretch、flex-start、flex-end、center 或 baseline stretch flex 与 grid 否 几何
:align-content normal、start、end、stretch、flex-start、flex-end、center、space-between、space-around 或 space-evenly stretch flex 与 grid 否 几何
:row-gap 非负块轴长度 (lh 0) flex 与 grid 否 几何
:column-gap 非负行内轴长度 (px 0) flex 与 grid 否 几何
:gap 1–2 个非负长度 — flex 与 grid 否 几何
:order 整数 0 所有非 text 节点 否 几何
:flex-grow 非负数字 0 所有非 text 节点 否 几何
:flex-shrink 非负数字 1 所有非 text 节点 否 几何
:flex-basis auto、min-content、max-content、fit-content、stretch 或非负长度 auto 所有非 text 节点 否 几何
:align-self auto、normal、start、end、stretch、flex-start、flex-end、center 或 baseline auto 所有非 text 节点 否 几何
:flex 非负数字、none、auto、initial,或 (grow shrink basis) — 所有非 text 节点 否 几何
:grid-template-columns nil 或列轨道列表 nil grid 否 几何
:grid-template-rows nil 或行轨道列表 nil grid 否 几何
:grid-auto-columns auto、单条轨道,或含一条轨道的一元列表 auto grid 否 几何
:grid-auto-rows auto、单条轨道,或含一条轨道的一元列表 auto grid 否 几何
:grid-auto-flow row 或 column row grid 否 结构
:grid-column nil、auto、正整数、(N)、(START :span SPAN)、(:span SPAN) 或 (START END) auto 所有非 text 节点 否 几何
:grid-row nil、auto、正整数、(N)、(START :span SPAN)、(:span SPAN) 或 (START END) auto 所有非 text 节点 否 几何
:grid-column-span 正整数 — 所有非 text 节点 否 几何
:grid-row-span 正整数 — 所有非 text 节点 否 几何
:justify-items stretch、start、end 或 center stretch grid 否 几何
:justify-self auto、stretch、start、end 或 center auto 所有非 text 节点 否 几何
:position static、relative 或 absolute static 所有非 text 节点 否 几何
:left 有符号行内轴长度 (px 0) 所有非 text 节点 否 几何
:top 有符号块轴长度 (lh 0) 所有非 text 节点 否 几何
:z-index 整数 0 所有非 text 节点 否 绘制
:layer local 或 root local 所有非 text 节点 否 几何
:anchor nil、符号或字符串 nil 所有非 text 节点 否 几何
:placement bottom-start、bottom-end、top-start 或 top-end bottom-start 所有非 text 节点 否 几何
:text-align left、center、right;end 等同 right,其他值等同 left left 仅 box 是 几何
:wrap-mode word、char、kp 或 none word 所有非 text 节点 是 几何
:overflow visible、hidden、scroll 或 auto scroll 所有非 text 节点 否 绘制 + 几何
:scroll-anchor start 或 end start 所有非 text 节点 否 几何
:outer inline 或 block block 所有非 text 节点 否 结构 + 几何