css文本制作
CSS文本样式基础
设置文本颜色使用color属性,支持十六进制、RGB或颜色名称:
p {
color: #FF5733;
}
调整字体大小通过font-size属性,单位可用px、em或rem:
h1 {
font-size: 2rem;
}
字体与字重控制
指定字体族使用font-family,建议设置备用字体:
body {
font-family: 'Arial', sans-serif;
}
控制字体粗细用font-weight属性,支持数值或关键词:

strong {
font-weight: 700;
}
文本对齐与装饰
文本水平对齐使用text-align属性:
article {
text-align: justify;
}
添加文本装饰线通过text-decoration:
a {
text-decoration: none;
}
行高与间距调整
设置行高用line-height属性,推荐无单位值:

p {
line-height: 1.6;
}
控制字母间距通过letter-spacing:
h2 {
letter-spacing: 1px;
}
高级文本效果
添加文本阴影使用text-shadow:
.title {
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
处理溢出文本通过text-overflow:
.truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}






