现在的互联网前端三层:
HTML 超文本标记语言 从语义的角度描述页面结构。
CSS 层叠式样式表 从审美的角度负责页面样式。
JS JavaScript 从交互的角度描述页面行为。
css整体感知
css是cascading style sheet 层叠式样式表的简写。“层叠式”的意思,我们将慢慢的去理解。
1 <style type="text/css">
2 p{
3 color:red;
4 font-size: 30px;
5 text-decoration: underline;
6 font-weight: bold;
7 text-align: center;
8 font-style: italic;
9 }
10 h1{
11 color:blue;
12 font-size: 50px;
13 font-weight: bold;
14 background-color: pink;
15 }
</style>
我们写css的地方是style标签,就是“样式”的意思,写在head里面。
后面的课程你将知道,css也可以写在单独的文件里面,现在我们先写在style标签里面
1<style type=”text/css”>
</style>
type表示“类型” , text就是“纯文本”。css也是纯文本的。
css对换行不敏感,对空格也不敏感。但是一定要有标准的语法。冒号,分号都不能省略。
CSS常见属性
字符颜色:
1color:red;
color属性的值,可以是英语单词,比如red、blue、yellow等等;也可以是rgb、十六进制,不要着急,后几天讲。
sublime中的快捷键是c,然后tab
字号大小:
1font-size:40px;
font就是“字体”,size就是“尺寸”。px是“像素”。
单位必须加,不加不行。
sublime中的快捷键是fos,然后tab
背景颜色:
1background-color: blue;
background就是“背景”。
sublime中的快捷键是bgc,然后tab
加粗:
1font-weight: bold;
font是“字体” weight是“重量”的意思,bold粗。
sublime中的快捷键是fwb,然后tab
不加粗:
1font-weight: normal;
normal就是正常的意思
sublime中的快捷键是fwn,然后tab
斜体:
1font-style: italic;
italic就是“斜体”
sublime中的快捷键是fsi,然后tab
不斜体:
1font-style: normal;
sublime中的快捷键是fsn,然后tab
下划线:
1text-decoration: underline;
decoration就是“装饰”的意思。
sublime中的快捷键是tdu,然后tab
没有下划线:
1text-decoration:none;
sublime中的快捷键是tdn,然后tab
网友评论