gpt4 book ai didi

css - 花哨的 CSS 阴影,可能吗?

转载 作者:行者123 更新时间:2023-12-02 04:44:54 27 4
gpt4 key购买 nike

我目前正在用 HTML/CSS 编写一个 PSD 文件,设计师使用了一些花哨的阴影。我想不出一种在 CSS 中做到这一点的方法——这可能吗? - 如果是,怎么做?

这是阴影:

enter image description here

最佳答案

根据 thgaskell 的建议链接,您可以使用#box:before 和#box:after 添加 2 个略小且索引低于 0 的框并向它们添加阴影。也将阴影的颜色用作这些背景颜色。

这是一个尝试执行此操作的代码笔(您可以调整它以适合您的目的): http://codepen.io/walmik/pen/fyidv

这是对您附加的图像进行了更多调整的另一个: http://codepen.io/walmik/pen/eqpGk

HTML:

<div id='box'>Fancy Shadow</div>

CSS:

#box {
position: relative;
width: 600px;
height: 300px;
padding: 20px;
background: #fff;
text-align: center;
font-size: 24px;
color: #333;
font-family: Georgia. serif;
box-shadow: 0px 0px 2px #888;
}

#box:before, #box:after
{
/*this is like appending a div element before the box:*/
z-index: -1;
position: absolute;
content: "";
bottom: 0px;
left: 0px;
width: 45%;
height: 60%;
top: 15px;
max-width:300px;
background: #888;
-webkit-box-shadow: -2px -15px 30px #888;
-moz-box-shadow: -2px -15px 30px #888;
box-shadow: -2px -15px 30px #888;
}

#box:after
{
/*this is like appending a div element after the box:*/
right: 3px;
left: auto;
-webkit-box-shadow: 2px -15px 30px #888;
-moz-box-shadow: 2px -15px 30px #888;
box-shadow: 2px -15px 30px #888;
-webkit-transform: rotate(1deg);
-moz-transform: rotate(1deg);
-o-transform: rotate(1deg);
-ms-transform: rotate(1deg);
transform: rotate(1deg);
}

关于css - 花哨的 CSS 阴影,可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19987888/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com