CSS 仅左侧和右侧的框阴影
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17416881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Box-Shadow Only on Left and Right
提问by L84
I am attempting to create an inset box-shadow on an element that only has the shadow on the left and right. I cannot get it to work.
我试图在一个只有左右阴影的元素上创建一个插入框阴影。我无法让它工作。
Here is the box-shadow I tried:
这是我试过的盒子阴影:
box-shadow: inset 10px 0px 25px 0px rgba(0,0,0,0.45);
I will add another one for the right side. The problem is this setting also shows the shadow slightly on the top and bottom and I cannot get it to not show and still show a shadow on the left side. Is this possible?
我会为右侧添加另一个。问题是这个设置还在顶部和底部稍微显示了阴影,我无法让它不显示并且仍然在左侧显示阴影。这可能吗?
回答by Antony
Use a negative value on spread-radius (4th value)to shrink the shadow. This can hide the unwanted top and bottom shadow.
在spread-radius上使用负值(第 4 个值)来缩小阴影。这可以隐藏不需要的顶部和底部阴影。
box-shadow: inset 25px 0px 25px -25px rgba(0,0,0,0.45), inset -25px 0px 25px -25px rgba(0,0,0,0.45);
See DEMO.
见演示。