1 字体属性
.family {
/* 定义文本字体,字体间用逗号隔开,多单词加引号,显示时优先级递进,前一个无法显示就用后一个 */
font-family: serif;
}
.size {
/* 定义字体大小,一定要加单位px,标题标签需要单独指定 */
font-size: 80px;
}
.weight {
/* 定义文本粗细,normal 正常、bold 加粗、bolder 特粗、lighter 加细、89(无单位) */
font-weight: bolder;
}
.style {
/* 设置文本风格,normal 正常、italic 斜体 */
font-style: italic;
}
.mix {
/* 复合属性,格式为font: font-style font-weight font-size/line-height font-family */
/* 顺序不能颠倒,必须保留size和family,不需要的属性可以忽略 */
font: italic lighter 100px 'Microsoft yahei';
}
2 文本属性
.text {
/* 定义颜色,预定义颜色redgreen/十六进制#ff0000/rgb形式rgb(255,0,0) */
color: pink;
/* 水平对齐 center/right/left(默认) */
text-align: center;
/* 装饰文本 none(默认)/underline(下划线)/overline(上划线)/line-through(删除线) 常用于取消<a>的下划线 */
text-decoration: line-through;
/* 文本缩进,即段落首行缩进,可以取负值,单位可以是px或em(当前元素一个字符的大小) */
text-indent: 2em;
/* 行间距,只能为正值,上下两行距离=(设置值-字体大小)/2 */
line-height: 80px;
}
3 背景属性
.bgc {
/* 背景颜色 */
background-color: red;
height: 100px;
/* 背景色半透明 */
background: rgba(255, 0, 0, 0.3);
}
.bgi {
background-color: orange;
height: 1000px;
/* 背景图 background-image:none/url()*/
background-image: url(1.jpg);
/* 背景平铺 background-repeat: no-repeat/repeat(默认)/repeat-x/repeat-y*/
background-repeat: no-repeat;
/* 图片位置 background-position: center/top/botton/left/right/x y(精确的坐标,只有一个坐标时另一个居中,可以是数字加单位或者是百分数)*/
background-position: center;
/* 背景固定/附着 scroll:默认 随对象内容滚动 fixed:固定*/
background-attachment: fixed;
}
/* 复写写法:background: 颜色 图片 平铺 附着 位置(写法的顺序没有影响) */