0
点赞
收藏
分享

微信扫一扫

box-shadow的属性的探究


<!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 {
padding: 20px 40px;
}

.box {
margin-top: 40px;
width: 200px;
height: 80px;
line-height: 80px;
border-radius: 5px;
text-align: center;
border: 1px solid #f2f2f2;
}

.box:nth-of-type(1) {
box-shadow: 20px 10px yellowgreen;
}

.box:nth-of-type(2) {
box-shadow: 20px 10px 5px yellowgreen;
}

.box:nth-of-type(3) {
box-shadow: 20px 10px 5px 8px yellowgreen;
}

.box:nth-of-type(4) {
box-shadow: 5px 5px 12px 0 yellowgreen inset;
}

.divider {
margin: 30px 0;
width: 100%;
height: 1px;
background-color: #b4bcc9;
}

.wrapper {
margin-bottom: 15px;
display: flex;
}

.header {
font-size: 17px;
font-weight: 600;
margin-top: 35px;
}

.wrapper div {
width: 120px;
height: 120px;
background-color: #ffa600;
border-radius: 5px;
margin-right: 150px;
}

.offset-x div:nth-of-type(1) {
box-shadow: 20px 0px 10px 0px rgba(0, 0, 0, 0.5);
}

.offset-x div:nth-of-type(2) {
box-shadow: -20px 0px 10px 0px rgba(0, 0, 0, 0.5);
}

.offset-y div:nth-of-type(1) {
box-shadow: 0px 20px 10px 0px rgba(0, 0, 0, 0.5);
}

.offset-y div:nth-of-type(2) {
box-shadow: 0px -20px 10px 0px rgba(0, 0, 0, 0.5);
}

.blur div:nth-of-type(1) {
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.5)
}

.blur div:nth-of-type(2) {
box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.5)
}

.blur div:nth-of-type(3) {
box-shadow: 0px 0px 50px 0px rgba(0, 0, 0, 0.5)
}

.spread div:nth-of-type(1) {
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.5)
}
.spread div:nth-of-type(2) {
box-shadow: 0px 0px 20px 20px rgba(0, 0, 0, 0.5)
}
.spread div:nth-of-type(3) {
box-shadow: 0px 0px 50px 50px rgba(0, 0, 0, 0.5)
}

.color div:nth-of-type(1) {
box-shadow: 0px 0px 20px 10px #e00798
}
.color div:nth-of-type(2) {
box-shadow: 0px 0px 20px 10px rgba(0,0,0,0.5)
}

.position div:nth-of-type(1) {
box-shadow: 0px 0px 20px 10px #1a2bc7;
text-align: center;
line-height: 120px;
}
.position div:nth-of-type(2) {
box-shadow: 0px 0px 20px 10px rgba(0,0,0,0.5) inset;
text-align: center;
line-height: 120px;
}

.mult div:nth-of-type(1) {
box-shadow: 0px 10px 10px #1a2bc7, -8px -5px 16px #e70764, 10px 0px 10px #3007e7;
}</style>
</head>

<body>
<h1>css box-shadow</h1>
<p class="attr">
box-shadow: h-shadow(水平) v-shadow(垂直) blur(模糊距离) spread(阴影尺寸) color(阴影颜色) inset(将默认外部阴影改为内部阴影);
</p>

<p class="attr">
box-shadow属性由5部分组成: offset-x offset-y blur spread color position。
</p>

<div class="box">
I am a box!
</div>

<div class="box">
I am a box!
模糊距离
</div>

<div class="box">
I am a box!
阴影尺寸
</div>

<div class="box">
I am a box!
内部阴影
</div>

<div class="divider"></div>

<p>
box-shadow: offset-x offset-y blur spread color position;
</p>

<p class="header">offset-x 阴影水平方向的偏移</p>
<div class="wrapper offset-x">
<div></div>
<div></div>
</div>

<p class="header">offset-y 阴影竖直方向的偏移</p>
<div class="wrapper offset-y">
<div></div>
<div></div>
</div>

<p class="header">blur 模糊半径</p>
<div class="wrapper blur">
<div></div>
<div></div>
<div></div>
</div>

<p class="header">spread 阴影扩展半径,其值可以是正负值,如果值为正,则整个阴影都延展扩大,反之值为负值是,则缩小</p>
<div class="wrapper spread">
<div></div>
<div></div>
<div></div>
</div>

<p class="header">color 阴影的颜色</p>
<div class="wrapper color">
<div></div>
<div></div>
</div>

<p class="header">position 不设值,其默认的投影方式是外阴影;设置阴影类型为“inset”时,其投影就是内阴影</p>
<div class="wrapper position">
<div>外阴影</div>
<div>内阴影</div>
</div>

<div class="divider"></div>

<p>多个box-shadow值叠加</p>
<div class="wrapper mult">
<div></div>
</div>
</body>

</html>

box-shadow的属性的探究_css


举报

相关推荐

0 条评论