3561

18 分钟

#CSS 常用属性

#文本属性

属性说明
color设置文本颜色
font-family设置字体族
font-size设置字体大小
font-weight设置字体粗细
font-style设置字体样式(斜体等)
text-align设置文本对齐方式
text-decoration设置文本装饰(下划线等)
line-height设置行高
letter-spacing设置字符间距
word-spacing设置单词间距
text-transform控制文本大小写
text-indent设置首行缩进
text-shadow设置文本阴影

#背景属性

属性说明
background-color设置背景颜色
background-image设置背景图像
background-repeat设置背景图像重复方式
background-position设置背景图像位置
background-attachment设置背景图像是否固定
background-size设置背景图像尺寸
background-clip设置背景绘制区域
background-origin设置背景定位区域

#盒模型属性

属性说明
width设置元素宽度
height设置元素高度
margin设置外边距
padding设置内边距
border设置边框
border-radius设置边框圆角
box-shadow设置盒子阴影
box-sizing设置盒模型计算方式
overflow设置内容溢出时的行为

#定位属性

属性说明
position设置定位方式
top设置定位元素的上偏移
right设置定位元素的右偏移
bottom设置定位元素的下偏移
left设置定位元素的左偏移
z-index设置堆叠顺序
float设置浮动
clear清除浮动

#布局属性(Flexbox)

属性说明
display设置显示方式
flex-direction设置主轴方向
flex-wrap设置是否换行
flex-flowflex-directionflex-wrap的简写
justify-content设置主轴对齐方式
align-items设置交叉轴对齐方式
align-content设置多行对齐方式
order设置项目排序顺序
flex-grow设置项目放大比例
flex-shrink设置项目缩小比例
flex-basis设置项目初始大小
flexflex-grow, flex-shrinkflex-basis的简写
align-self设置单个项目对齐方式

#布局属性(Grid)

属性说明
grid-template-columns定义列轨道大小
grid-template-rows定义行轨道大小
grid-template-areas定义网格区域
grid-template上述三个属性的简写
grid-column-gap设置列间距
grid-row-gap设置行间距
grid-gap设置行列间距简写
justify-items设置单元格内容水平对齐
align-items设置单元格内容垂直对齐
place-itemsalign-itemsjustify-items的简写
justify-content设置网格水平对齐
align-content设置网格垂直对齐
place-contentalign-contentjustify-content的简写
grid-auto-columns设置隐式创建的列轨道大小
grid-auto-rows设置隐式创建的行轨道大小
grid-auto-flow设置自动放置算法
grid多个网格属性的简写

#过渡和动画属性

属性说明
transition设置过渡效果
transition-property设置过渡属性
transition-duration设置过渡持续时间
transition-timing-function设置过渡速度曲线
transition-delay设置过渡延迟时间
animation设置动画
animation-name设置动画名称
animation-duration设置动画持续时间
animation-timing-function设置动画速度曲线
animation-delay设置动画延迟时间
animation-iteration-count设置动画播放次数
animation-direction设置动画播放方向
animation-fill-mode设置动画填充模式
animation-play-state设置动画播放状态

#变换属性

属性说明
transform应用2D或3D变换
transform-origin设置变换原点
transform-style设置子元素是否保留3D位置
perspective设置3D元素的透视视图
perspective-origin设置3D元素的底部位置
backface-visibility设置元素背面是否可见

#其他属性

属性说明
opacity设置透明度
visibility设置元素可见性
cursor设置鼠标指针样式
clip裁剪绝对定位元素
clip-path使用裁剪方式创建元素显示区域
filter应用图形效果
mix-blend-mode设置元素内容如何与父元素和背景混合
object-fit指定替换元素的内容如何适应容器
object-position指定替换元素的内容在容器中的位置
resize设置元素是否可调整大小
user-select控制用户能否选择文本
pointer-events控制元素如何响应鼠标事件

创建于 2025/5/22

更新于 2025/5/22