阴影:
- x方向阴影的位移,y方向上阴影的位移, 阴影的模糊程度,阴影的颜色和其透明度,inset为内部
<!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>Document</title>
<style>
.shadow1 {
height: 100px;
width: 100px;
border: 1px solid #000;
box-shadow: 10px 10px 10px #95215e;
}
.shadow2 {
height: 100px;
width: 100px;
border: 1px solid #000;
box-shadow: -10px -10px 10px #95215e;
}
.shadow3 {
height: 100px;
width: 100px;
border: 1px solid #000;
box-shadow: 0px -10px 10px #95215e inset;
}
.shadow4 {
height: 100px;
width: 100px;
border: 1px solid #000;
box-shadow: 0px 0px 10px #aaa;
}
</style>
</head>
<body>
<div>阴影效果:</div>
<div style="margin-top: 20px"></div>
<div class="shadow1"></div>
<div class="shadow2" style="margin-top: 40px"></div>
<div class="shadow3" style="margin-top: 40px"></div>
<div class="shadow4" style="margin-top: 40px"></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>Document</title>
<style>
body {
background-color: #000;
}
div {
position: absolute;
top: calc(50% - 150px);
left: calc(50% - 150px);
width: 300px;
height: 300px;
border-radius: 50%;
box-shadow: inset 0 0 50px #fff, inset 20px 0 80px #f0f, inset -20px 0 80px #0ff, inset 20px 0 300px #f0f,
inset -20px 0 300px #0ff, 0 0 50px #fff, -10px 0 80px #f0f, 10px 0 80px #0ff;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
渐变:
- 线性渐变(Linear Gradients)- 向下/向上/向左/向右/对角方向deg/颜色
- 颜色支持rgba,设置透明,注意兼容性,还可以后面加百分比
- 径向渐变(Radial Gradients)- 由它们的中心定义- circle/ellipse/颜色
<!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>Document</title>
<style>
.div1 {
width: 100px;
height: 50px;
background: -webkit-linear-gradient(#00c7a6, red);
background: -o-linear-gradient(#00c7a6, red);
background: -moz-linear-gradient(#00c7a6, red);
background-image: linear-gradient(-90deg, red, yellow, #ccc);
}
.div2 {
width: 100px;
height: 100px;
background-image: radial-gradient(circle, red 10%, yellow, green);
margin-top: 60px;
}
</style>
</head>
<body>
<div class="div1"></div>
<div class="div2"></div>
</body>
</html>