使用 CSS 设置插入和起始框阴影

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22438457/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:06:50  来源:igfitidea点击:

Set both inset and outset box shadow using CSS

css

提问by Iter Ator

The box-shadowproperty has a property value called inset, so the shadow can be inset, or outset.

box-shadow属性有一个名为 的属性值inset,因此阴影可以是insetoutset

But how is it possible, to set both inset, and outsetshadow for a divin CSS?

但是如何在 CSS 中为 a设置insetoutset阴影div呢?

回答by Mr. Alien

You need to separate them using a ,

您需要使用 a 将它们分开 ,

div {
    margin: 100px;
    height: 100px;
    width: 100px;
    border: 1px solid #aaa;
    border-radius: 50%;
    box-shadow: inset 0 0 5px tomato, 0 0 5px black;
}

Demo

Demo

Demo 2(Nothing different, but used whiteborderfor better indication)

Demo 2(没有什么不同,但用于whiteborder更好的指示)

So here in the above example, it sets the shadow insetwith the tomatocolor, and the other set of rules separated using a comma is for outseti.e blackshadow

所以在上面的例子中,它用颜色设置阴影插入tomato使用逗号分隔的另一组规则用于开始,black阴影

回答by newTag

You need to use comma to separate both shadows.

您需要使用逗号分隔两个阴影。

div{
    top: 100px;
    position: absolute;
    left: 100px;
    height: 100px;
    width: 100px;
    box-shadow: 10px 10px 10px grey, 0 0 10px black;
    border-radius: 5px;
    background: white;
}

See demo

看演示