字体属性
-
- font-family:"微软雅黑"; 字体
-
-
- p{font-family:'宋体';}
- div{font-family:Arial,"Microsoft Yahei","微软雅黑";}
-
-
- font-size 单位为px 字体大小
-
-
- 标题标签比较特殊,需要单独指定文字大小
- p{font-size:20px;}
-
-
- font-weight 字体的粗细
-
-
- 默认normal正常的字体 400
- bold 变粗 700
- bolder 特粗体
- lighter 细体
- number 数字表示粗细,不加单位
-
-
- font-style 字体的样式(斜体)
-
-
- normal 默认值
- italic 斜体显示
-
-
- font的复合属性写法
-
-
- font:font-style font-weight font-size/line-height font-family;
- eg:font:italic 700 16px ‘microsoft yahei'
- 顺序不能更换,最后2个不能省略。
-
文本属性
CSS Text文本属性可定义文本的外观,比如颜色,对齐方式,装饰文本,文本缩进,行间距。
-
-
- color 改变文字颜色
-
-
-
-
- color:red;
- color:#ffffff;
- color:rgb(255,255,255)or rgb(100%,0%,0%)
-
-
-
-
- text-align对齐文本
-
-
-
-
- center
- left 默认
- right
-
-
-
-
- text-decoration装饰文本
-
-
-
-
- none 默认,没有装饰线
- underline 下划线
- overline 上划线
- line-through 删除线
-
-
-
-
- text-indent 文本缩进
-
-
-
-
- text-indent:10px;
- em是一个相对单位,就是当前元素1个文字的大小
-
-
-
-
- line-height行间距
-
-
-
-
- line-height:26px;
-
-
CSS的引入方式
- 行内样式表(行内式)
-
- 在标签内部的style属性中进行设置
- <div style="color:red;font-size:12px;">???</div>
- 内部样式表(嵌入式)
-
- 写在HTML内部,放在<style></style>中
- <style>要放入<head>中
- 外部样式表(链接式)
-
- 单独建立一个CSS文件,把CSS引入HTML中
- 新建一个后缀名为.css的文件,把所有的css代码放入此文件中
- 在HTML页面中,使用<link>标签引入这个文件
-
-
- <link rel="stylesheet" href="css文件路径">
- rel引入的那个样式表
- <link rel="stylesheet" href="style.css">
-
chrome调试工具
F12或右键检查-> elements
实例练习: