1,shadow--box-shadow 向框添加一个或多个阴影。该属性是由逗号分隔的阴影列表,每个阴影由 2-4 个长度值、可选的颜色值以及可选的 inset 关键词来规定。
box-shadow: 10px 10px 5px #888888;
h-shadow 必需。水平阴影的位置。允许负值。
v-shadow 必需。垂直阴影的位置。允许负值。
blur 可选。模糊距离。
spread 可选。阴影的尺寸。
color 可选。阴影的颜色。请参阅 CSS 颜色值。
inset 可选。将外部阴影 (outset) 改为内部阴影。
2,gradient--渐变,css函数
linear-gradient() | 将线性渐变设置为背景图像。定义至少两种颜色(从上到下)。 |
radial-gradient() | 将径向渐变设置为背景图像。定义至少两种颜色(从中心到边缘)。 |
repeating-linear-gradient() | 重复线性渐变。 |
repeating-radial-gradient() | 重复径向渐变。 |
background-image: linear-gradient(red, yellow, blue);
应用实例--彩虹
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>gradient</title>
<style>
*{
margin: 0;
padding: 0;
}
.d1 {
width: 700px;
height: 300px;
background-color: cyan;
background-image: -webkit-radial-gradient(center bottom, white 30%,plum 30%, plum 35%,
deepskyblue 35%, deepskyblue 40%,
cyan 40%, cyan 45%,
greenyellow 45%, greenyellow 50%,
gold 50%, gold 55%,
orange 55%, orange 60%,
tomato 60%, tomato 65%,white 65%);
}
</style>
</head>
<body>
<div class="d1"></div>
</body>
</html>
运行结果
应用案例--手机滑动解锁
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>模仿苹果手机滑动解锁效果</title>
<style>
* {
margin: 0;
padding: 0;
list-style: none;
}
div {
width: 500px;
height: 500px;
background-color: #333;
}
p {
width: 400px;
height: 100px;
font-size: 40px;
line-height: 100px;
text-align: center;
color: transparent;
background-color:tomato;
background-image: -webkit-linear-gradient(left top, transparent 30%, #fff 38%, transparent 46%);
/* 过渡 */
transition: 1s;
/* 背景剪裁 */
-webkit-background-clip: text;
}
p:hover {
cursor: pointer;
background-position: 400px 0;
}
</style>
</head>
<body>
<div>
<p>向右滑动进行解锁</p>
</div>
</body>
</html>
运行结果