一、在HTML中引入css
1、行间样式
<div style=" "></div>
2、页面级css
<head>
<style type="text/css">
div{ }
</style>
3、外部css文件
<head>
<link rel="stylesheet" type="text/css" href="css文件地址">
异步的:同时进行(异步加载)
同步的:加载一个在进行下一个
二、选择器
1、id:一一对应(id值只有一个)
<div id="a1"></div>
css中 #a1{ }
2、class 多对多
(1)<div class="demo"></div>
<div class="demo"></div>
(2)<div class="demo,demo1"></div>
3、标签选择器
div{ }
span{ }
4、通配符
*(任意的意思,即对所有标签)
*{ }
5、属性选择器
[id="b1",style=" "]{ }
6、(1)父子选择器
<div>
<span>
<p>
</p>
</span>
</div>
div span{ }
div p{ }
(2)直接子元素选择器
1)<div>
<em> 1 </em>
<span> <em> 2 </em> </span>
</div>
div>em{ }(对1进行修饰)
2)selection div ul li a em (从右向左查找)
(3)分组选择器
<em>1</em>
<strong>2</strong>
<span>3</span>
em,strong,span{ }
7、伪类选择器
<a href=" "></a>
a:hover{ }
三、属性
1、font
font-size:字体大小,默认是16px
font-weight:lighter normal bold bolder (字体粗细)
100 200~~900
font-style:italic(斜体)
font-family(字体):arial
color(字体颜色):
2、background(css背景)
background-color(背景颜色)
background-image(背景图片)
background-repeat(如果不想让图片平铺,可以用此属性)
background-attacment:
background-position(设置背景图片的起始位置)
3、border(边框)
border:1px solid black
border-width border-style border-color
4、text-align(对齐方式):center,right,left
5、line-height(文本高度)
6、text-indent(文本缩进):1em;
1em=1*font-size
7、text-decoration:none(无下划线),underline(下划线)
8、cursor:pointer(小手)
四、盒子模型