html - 是否可以在容器内提供阴影?

标签 html css shadow box-shadow

.part-two{
                float: left;
                height:300px;
                width: 200px;
                background-color:green;
                box-shadow: -10px -10px 1px red;
            }
<div id="part-two" class="part-two">
                </div>

在上面的代码中,我使用 box-shadow 属性给出了一个外部阴影,而不是我想在容器内部给出阴影,是否可以使用 box-shadow 方法给出内部阴影?如果是,如何? 否则,是否有任何方法可以使用 css 提供内部阴影?

最佳答案

是的,可以将 inner-shadow 添加到元素中,您只需要在 中添加 inset 以及 properties >盒子阴影

The presence of the inset keyword changes the shadow to one inside the frame (as if the content was depressed inside the box). Inset shadows are drawn inside the border (even transparent ones), above the background, but below content.

.part-two{
                float: left;
                height:300px;
                width: 200px;
                background-color:green;
                box-shadow: inset 0px 1px 10px 20px orange;
}
<div id="part-two" class="part-two">
</div>

关于html - 是否可以在容器内提供阴影?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39614841/

相关文章:

html - 将 li float 到网格模式中会留下不需要的间距

javascript - 如何更改 PrimeFaces onclick 按钮中的选项卡?

javascript - 将类添加到具有特定类的元素

android - 如何在 SurfaceView 中禁用硬件加速?

wpf - 如何在silverlight中在网格周围设置阴影?

javascript - Jquery 选择器,我应该指定 html 标签的类型吗?

html - 如何为图像设置自适应背景?

php - 根据特定条件将来自 my_MySQL 的值分组显示在单独的 <div> 中

javascript - 当元素在 AngularJS 中可见时运行一些 DOM 操作

javascript - 在 CSS/jQuery 中的旋转元素上保持相同方向的阴影