0%

第五天

第五天

CSS图片处理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>图片解决方案</title>
<style>
ul{
list-style:none;
}
a{
text-decoration: none;
color: #999;
}
/* 普通背景图片处理 */
.tlist>li{
height: 30px;
line-height: 30px;
background-image: url(./dot_red.gif);
background-repeat: no-repeat;
background-position: 0 15px;/* 调整图片上下的位置 */
padding-left: 12px; /* 调整图片左右的位置 */
}

/* 雪碧图使用 */
.miaosha{
width: 40px;
height: 40px;
background: transparent url(zhekouicon_bg.gif) no-repeat -126px -343px;
/* css sprite 的background-position一定是负值或0 */
}
.other{
width: 40px;
height: 40px;
background: transparent url(zhekouicon_bg.gif) no-repeat -85px -343px;
}

.img,.img2{
width: 300px;
height: 300px;
border: 1px solid #c00;
background: url(zhekouicon_bg.gif);
}
.img{
/* 属性值为一个值则为宽度,高度随着宽度等比例变化 */
/* background-size: contain; */
block-size: 100%;
}

.img2{
background-size: cover;
background-clip: content-box;/* 只为内容加背景图片,padding部分不加 */
padding: 20px;
}
</style>
</head>
<body>
<!-- 1.电脑端:css sprite 雪碧图,css精灵 -->
<!-- 将多张辅助(背景)合并为一张图片 -->
<!-- 2.移动端 -->
<!-- 图像软件:fireworks、photoshop、画图 -->
<!-- 做设计图,切图 -->
<ul class="tlist">
<li><a href="#">这里是列表的内容</a></li>
<li><a href="#">这里是列表的内容</a></li>
<li><a href="#">这里是列表的内容</a></li>
<li><a href="#">这里是列表的内容</a></li>
</ul>
<div class="miaosha">
</div>
<div class="other">

</div>

<div class="img">

</div>
<div class="img2"></div>
</body>
</html>

移动端图片处理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>移动端图片处理</title>
<link rel="stylesheet" href="./iconfont/iconfont.css">
<style>
span.iconfont{/* 优先级问题 */
font-size: 150px;
}
.iconfont:first-child{
color: red;
}
</style>
</head>

<body>
<!-- 移动端图片解决方案 -->
<!-- 1.png、jpg -->
<!-- 2.iconfont字体图标,使用文字作为图标,@font-face-服务器端字体 -->
<!-- 3.svg:ai -->
<!-- 4.base64 -->
<span class="iconfont icon-heart"></span>
</body>

</html>

下导航实例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>下导航</title>
<link rel="stylesheet" href="./iconfont/iconfont.css">
<style>
ul,p,body{
margin: 0;
padding: 0;
}
ul{
list-style: none;
}
.fnav{
width: 100%;
position: fixed;
left: 0;
bottom: 0;
display: flex;
}
.fnav>li{
width: 20%;
text-align: center;
}
.fnav>li:nth-child(3) .iconfont{
font-size: 40px;
color: #666;
line-height: 50px;
}
.iconfont{
font-size: 32px;
color: #999;
line-height: 50px;
}
.fnav p{
line-height: 30px;
font-size: 14px;
color: #999;
}
</style>
</head>

<body>
<ul class="fnav">
<li>
<span class="iconfont icon-heart"></span>
<p>精选</p>
</li>
<li>
<span class="iconfont icon-hearto"></span>
<p>新闻</p>
</li>
<li>
<span class="iconfont icon-down"></span>
<p>娱乐</p>
</li>
<li>
<span class="iconfont icon-like"></span>
<p>商城</p>
</li>
<li>
<span class="iconfont icon-like1"></span>
<p>我的</p>
</li>

</ul>
</body>

</html>

CSS3D动画

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>3D</title>
<style>
h2,p{
padding: 0;
margin: 0;
}
.view{
width: 300px;
height: 150px;
overflow: hidden;
perspective: 400px;/* 视图 */
/* perspective-origin: bottom left; 视觉的终点 */

margin: 4px;
}
.three{
transform-style: preserve-3d;
transform-origin: right center 0;/* 三个值 x,y,z */
position: relative;
width: 100%;
height: 100%;
transition: all 0.6s ease-in-out;
/* transform-style: preserve-3d; */
}
img{
width: 300px;
height: 150px;
}
.front,.back{
position: absolute;
backface-visibility: hidden;/* 3D旋转过程中后面是否可见 */
width: 100%;
height: 100%;
}
.back{
transform: rotateY(0.5turn);
}
.three:hover{
transform: translateX(-100%) rotateY(-180deg);
}

.back{
background: #c00;
}
.back h3{
margin: 10px;
font-size: 16px;
text-align: center;
}
.back p{
color: #fff;
text-indent: 2em;
font-size: 14px;
line-height: 25px;
padding: 3px;
}

</style>
</head>
<body>
<div class="view">
<div class="three">
<div class="front">
<img src="../Day1/3.jpg" alt="">
</div>
<div class="back">
<img src="../Day1/2.png" alt="">
</div>
</div>
</div>

<div class="view">
<div class="three">
<div class="front">
<img src="../Day1/2.png">
</div>
<div class="back">
<h3>这里是文字</h3>
</div>
</div>
</div>
</body>
</html>