字体样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| font | font-style font-variant font-weight font-size line-height font-family | 设置字体的综合属性 | font: italic small-caps bold 16px/2 sans-serif; |
| font-family | 'Arial', sans-serif | 定义文本的字体系列 | font-family: 'Arial', sans-serif; |
| font-size | px, em, rem, % | 设置字体大小 | font-size: 16px; |
| font-style | normal, italic, oblique | 设置字体的样式 | font-style: italic; |
| font-weight | normal, bold, 100-900 | 设置字体的粗细 | font-weight: bold; |
| font-variant | normal, small-caps | 设置字体的特殊样式,如小型大写字母 | font-variant: small-caps; |
| line-height | normal, number, length | 设置行高 | line-height: 1.5; |
| letter-spacing | normal, length | 设置字符间距 | letter-spacing: 2px; |
| word-spacing | normal, length | 设置单词间距 | word-spacing: 4px; |
文本样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| color | color | 设置文本颜色 | color: #000; |
| text-align | left, right, center, justify | 设置文本的水平对齐方式 | text-align: center; |
| text-decoration | none, underline, overline, line-through | 设置文本的装饰 | text-decoration: underline; |
| text-transform | none, uppercase, lowercase, capitalize | 设置文本的大小写转换 | text-transform: uppercase; |
| text-shadow | h-shadow v-shadow blur-radius color | 添加文本阴影效果 | text-shadow: 2px 2px 5px #000; |
| white-space | normal, nowrap, pre, pre-wrap, pre-line | 设置如何处理空白字符 | white-space: nowrap; |
| text-overflow | clip, ellipsis | 设置当文本溢出容器时的处理方式 | text-overflow: ellipsis; |
背景样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| background | color image position size repeat origin clip attachment | 设置背景的综合属性 | background: #fff url('image.jpg') no-repeat center; |
| background-color | color | 设置背景颜色 | background-color: #ff0; |
| background-image | url(image), none | 设置背景图片 | background-image: url('image.jpg'); |
| background-repeat | repeat, repeat-x, repeat-y, no-repeat | 设置背景图片的重复方式 | background-repeat: no-repeat; |
| background-size | auto, length, percentage, cover, contain | 设置背景图片的大小 | background-size: cover; |
| background-position | left, right, top, bottom, center, length, percentage | 设置背景图片的位置 | background-position: center; |
| background-attachment | scroll, fixed, local | 设置背景图片的附件 | background-attachment: fixed; |
边框样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| border | border-width border-style border-color | 设置边框的综合属性 | border: 1px solid #000; |
| border-width | thin, medium, thick, length | 设置边框的宽度 | border-width: 2px; |
| border-style | none, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset | 设置边框的样式 | border-style: solid; |
| border-color | color | 设置边框的颜色 | border-color: #000; |
| border-top | border-width border-style border-color | 设置上边框的综合属性 | border-top: 1px solid #000; |
| border-right | border-width border-style border-color | 设置右边框的综合属性 | border-right: 1px solid #000; |
| border-bottom | border-width border-style border-color | 设置下边框的综合属性 | border-bottom: 1px solid #000; |
| border-left | border-width border-style border-color | 设置左边框的综合属性 | border-left: 1px solid #000; |
| border-radius | length, percentage | 设置边框的圆角 | border-radius: 10px; |
布局样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| display | none, inline, block, inline-block, flex, grid, table, inline-table, list-item, run-in, compact, marker, table-column, table-column-group, table-footer-group, table-header-group, table-row, table-row-group, table-cell, ruby, ruby-base, ruby-text, ruby-base-container, ruby-text-container, contents | 设置元素的显示类型 | display: block; |
| position | static, relative, absolute, fixed, sticky | 设置元素的定位方式 | position: absolute; |
| top | auto, length, percentage | 设置元素顶部位置 | top: 10px; |
| right | auto, length, percentage | 设置元素右侧位置 | right: 10px; |
| bottom | auto, length, percentage | 设置元素底部位置 | bottom: 10px; |
| left | auto, length, percentage | 设置元素左侧位置 | left: 10px; |
| z-index | auto, number | 设置元素的堆叠顺序 | z-index: 10; |
| float | none, left, right | 设置元素的浮动 | float: left; |
| clear | none, left, right, both | 设置元素浮动清除 | clear: both; |
| overflow | visible, hidden, scroll, auto | 设置当内容溢出容器时的处理方式 | overflow: hidden; |
| visibility | visible, hidden, collapse | 设置元素的可见性 | visibility: hidden; |
| opacity | number (0-1) | 设置元素的不透明度 | opacity: 0.5; |
对齐样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| vertical-align | baseline, sub, super, top, text-top, middle, bottom, text-bottom, length, percentage | 设置元素的垂直对齐方式 | vertical-align: middle; |
| text-align-last | auto, left, right, center, justify, start, end | 设置最后一行的对齐方式 | text-align-last: justify; |
| align-items | stretch, center, flex-start, flex-end, baseline | 设置flex容器的子项在交叉轴上的对齐方式 | align-items: center; |
| justify-content | flex-start, flex-end, center, space-between, space-around, space-evenly | 设置flex容器的子项在主轴上的对齐方式 | justify-content: space-between; |
尺寸样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| width | auto, length, percentage | 设置元素的宽度 | width: 100px; |
| height | auto, length, percentage | 设置元素的高度 | height: 100px; |
| max-width | none, length, percentage | 设置元素的最大宽度 | max-width: 100%; |
| max-height | none, length, percentage | 设置元素的最大高度 | max-height: 100%; |
| min-width | length, percentage | 设置元素的最小宽度 | min-width: 50px; |
| min-height | length, percentage | 设置元素的最小高度 | min-height: 50px; |
边距和填充样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|-------------------|
--------------------------------------|----------------------------------------------------------------------|-----------------------------------------------------------|
| margin | auto, length, percentage | 设置外边距的综合属性 | margin: 10px; |
| margin-top | auto, length, percentage | 设置上外边距 | margin-top: 10px; |
| margin-right | auto, length, percentage | 设置右外边距 | margin-right: 10px; |
| margin-bottom | auto, length, percentage | 设置下外边距 | margin-bottom: 10px; |
| margin-left | auto, length, percentage | 设置左外边距 | margin-left: 10px; |
| padding | length, percentage | 设置内边距的综合属性 | padding: 10px; |
| padding-top | length, percentage | 设置上内边距 | padding-top: 10px; |
| padding-right | length, percentage | 设置右内边距 | padding-right: 10px; |
| padding-bottom | length, percentage | 设置下内边距 | padding-bottom: 10px; |
| padding-left | length, percentage | 设置左内边距 | padding-left: 10px; |
表格样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| border-collapse | collapse, separate | 设置表格的边框是否合并 | border-collapse: collapse; |
| border-spacing | length | 设置单元格之间的边框间距 | border-spacing: 10px; |
| caption-side | top, bottom | 设置表格标题的位置 | caption-side: top; |
| empty-cells | show, hide | 设置是否显示空单元格 | empty-cells: show; |
| table-layout | auto, fixed | 设置表格的布局方式 | table-layout: fixed; |
列表样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| list-style | list-style-type list-style-position list-style-image | 设置列表样式的综合属性 | list-style: disc inside none; |
| list-style-type | disc, circle, square, decimal, decimal-leading-zero, lower-roman, upper-roman, lower-greek, lower-alpha, upper-alpha, none | 设置列表项的标记类型 | list-style-type: circle; |
| list-style-position | inside, outside | 设置列表项标记的位置 | list-style-position: inside; |
| list-style-image | url(image), none | 设置列表项标记的图像 | list-style-image: url('image.png'); |
动画样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| @keyframes | name, keyframe-selector, properties | 定义动画的关键帧 | @keyframes slide { 0% { left: 0; } 100% { left: 100px; } } |
| animation | name duration timing-function delay iteration-count direction fill-mode play-state | 设置动画的综合属性 | animation: slide 2s linear 1s infinite alternate; |
| animation-name | none, keyframes | 设置动画的名称 | animation-name: slide; |
| animation-duration | time (e.g., 2s, 500ms) | 设置动画持续时间 | animation-duration: 2s; |
| animation-timing-function | ease, linear, ease-in, ease-out, ease-in-out, step-start, step-end, `steps(int,start | end), cubic-bezier(n,n,n,n)` | 设置动画的时间函数 |
| animation-delay | time (e.g., 2s, 500ms) | 设置动画的延迟时间 | animation-delay: 1s; |
| animation-iteration-count | infinite, number | 设置动画的播放次数 | animation-iteration-count: infinite; |
| animation-direction | normal, reverse, alternate, alternate-reverse | 设置动画的播放方向 | animation-direction: alternate; |
| animation-fill-mode | none, forwards, backwards, both | 设置动画的填充模式 | animation-fill-mode: both; |
| animation-play-state | running, paused | 设置动画的播放状态 | animation-play-state: running; |
变换样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| transform | none, transform-functions | 设置元素的变换方式 | transform: rotate(45deg); |
| transform-origin | x-axis y-axis z-axis | 设置变换的基点 | transform-origin: 50% 50%; |
| transform-style | flat, preserve-3d | 设置变换样式 | transform-style: preserve-3d; |
| perspective | none, length | 设置透视距离 | perspective: 1000px; |
| perspective-origin | x-axis y-axis | 设置透视基点 | perspective-origin: 50% 50%; |
| backface-visibility | visible, hidden | 设置背面是否可见 | backface-visibility: hidden; |
过渡样式属性
| 属性 | 可能的值 | 描述 | 示例 |
|---|
| transition | property duration timing-function delay | 设置过渡的综合属性 | transition: all 0.3s ease; |
| transition-property | none, all, property | 设置应用过渡效果的属性 | transition-property: opacity; |
| transition-duration | time (e.g., 2s, 500ms) | 设置过渡效果的持续时间 | transition-duration: 0.3s; |
| transition-timing-function | ease, linear, ease-in, ease-out, ease-in-out, step-start, step-end, `steps(int,start | end), cubic-bezier(n,n,n,n)` | 设置过渡效果的时间函数 |
| transition-delay | time (e.g., 2s, 500ms) | 设置过渡效果的延迟时间 | transition-delay: 0.1s; |