CSS
CSS三种导入方式
2. 选择器
2.1 基本选择器
-
标签选择器:选择一类标签 标签{ }
-
类选择器 class:选择所有class属性一致的标签,跨标签 .类名{ }
-
ID选择器:全局唯一 #id名{ }
优先级:id > class > 标签
2.2 层次选择器
2.3 结构伪类选择器
2.4 属性选择器
3. 美化网页元素
3.1 美化、字体样式
3.2 文本样式
颜色、对齐方式、行高、缩进、装饰
3.3 文本阴影 超链接伪类
3.4 列表
3.5 背景
3.6 渐变
4. 盒子模型
4.1 盒子
margin:外边距
padding:内边距
border:边框
4.2 边框
边框的粗细、颜色、样式
4.3 外边框
margin、padding
4.4 圆角边框
4.5 阴影
5. 浮动
5.1 display
行内元素可以被包含在块级元素中,反之则不可以。
display也是一种实现行内元素排列的方式,但是我们很多情况用float
5.2 float
左右浮动float
5.3 父级边框塌陷问题
解决方案:
5.4 对比
6. 定位
6.1 相对定位
练习:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#box{
width: 300px;
height: 300px;
padding: 10px;
border: 2px solid red;
}
a{
width: 100px;
height: 100px;
text-decoration: none;
line-height: 100px;
background-color: #ffa2fc;
color: white;
display: block;
text-align: center;
}
a:hover{
background-color: skyblue;
}
.a2,.a4{
position: relative;
left: 200px;
top: -100px;
}
.a5{
position: relative;
left: 100px;
top: -300px;
}
</style>
</head>
<body>
<div id="box">
<a class="a1" href="#"> 链接1 </a>
<a class="a2" href="#"> 链接2 </a>
<a class="a3" href="#"> 链接3 </a>
<a class="a4" href="#"> 链接4 </a>
<a class="a5" href="#"> 链接5 </a>
</div>
</body>
</html>
6.2 绝对定位
6.3 固定定位
6.4 z-index和透明度
z-index:默认是0,最高无限~999
7. 动画
canvas动画
css动画
菜鸟教程