我想创建这个页面(见图)与css阴影。这个是可能的吗?因此,要让页面剥离css框的阴影,左和右,以及左和右的阴影?

发布于 2015-06-25 22:49:38
您可以使用伪元素:before和:after来做到这一点。创建两个有自己的长方体阴影的新区域,并把它们放在需要的地方,你可以创造出阴影随着页面的下降而变大的错觉。
body {
background: lightgrey;
}
div {
background: white;
margin: 40px auto;
height: 500px;
width: 300px;
position: relative;
padding: 10px;
}
div:before,
div:after {
height: 97%;
z-index: -10;
position: absolute;
content: "";
bottom: 15px;
left: 8px;
width: 30%;
top: 2%;
max-width: 300px;
background: transparent;
box-shadow: -10px 0px 5px rgba(0, 0, 0, 0.3);
transform: rotate(1deg);
}
div:after {
transform: rotate(-1deg);
right: 8px;
left: auto;
box-shadow: 10px 0px 5px rgba(0, 0, 0, 0.3);
}<div>
test
</div>
另一种方法是使用CSS转换来改变单个:before伪元素的透视图。
body {
background: lightgrey;
}
div {
background: white;
margin: 40px auto;
height: 500px;
width: 300px;
position: relative;
padding: 10px;
box-shadow: 10px 0px 5px -10px gray, -10px 0px 5px -10px gray;
}
div:after {
content: '';
position: absolute;
bottom: 10px;
left: 0px;
height: 50%;
width: 100%;
transform-origin: 50% 100%;
transform: perspective(100px) rotateX(1deg);
box-shadow: 5px 0px 10px gray, -5px 0px 10px gray;
z-index: -1;
}<div></div>
https://stackoverflow.com/questions/30360606
复制相似问题