css字体
属性 | 表示 | 注意点 |
font-size | 字号 | 我们通常用的单位是px像素,一定要跟上单位 |
font-family | 字体 | 实际工作中按照团队约定来写字体 |
font-weight | 字体粗细 | 加粗700或bold,不加粗normal或400,数字不更单位 |
font-style | 字体样式 | 倾斜是italic,不倾斜是normal,工作中常用normal |
font | 字体连写 | 字体连写有顺序 不能随便换位置 其中字号和字体必须同时出现 |
属性 | 表示 | 注意点 |
color | 颜色 | 我们通常用十六进制 |
line-height | 行高 | 控制行与行之间的距离 |
text-align | 水平对齐 | 可以设置文字水平的对齐方式 |
text-indent | 首行缩颈 | 通常我们用于段落首行缩进2个字距离text-indent:2em |
text-decoration | 文本修饰 | 添加下划线underline 取消下划线 none |
引入css样式的方法
行内式
<标签名 style="属性1:属性值1; 属性2:属性值2; 属性3:属性值3;"> 内容 </标签名>
内部样式(内嵌式)
<head>
<style type="text/CSS">
选择器(选择的标签) {
属性1: 属性值1;
属性2: 属性值2;
属性3: 属性值3;
}
</style>
</head>
外部样式
<head>
<link rel="stylesheet" type="text/css" href="css文件路径">
</head>
css选择器
标签选择器
标签名{属性1:属性值1; 属性2:属性值2; 属性3:属性值3; }
类选择器
.类名 { 属性1:属性值1; 属性2:属性值2; 属性3:属性值3; }
id原则器
#id名 {属性1:属性值1; 属性2:属性值2; 属性3:属性值3; }
通配符选择器
* { 属性1:属性值1; 属性2:属性值2; 属性3:属性值3; }