gpt4 book ai didi

html - 为 "zigzag"边框插入阴影

转载 作者:行者123 更新时间:2023-11-28 00:00:39 27 4
gpt4 key购买 nike

我目前正在设计一个网站,我在页脚顶部创建了一个“之字形”边框。为了在网站中创建一些深度,我想在“之字形”中的三 Angular ​​形上添加阴影,这就是我目前遇到的问题。

这是我现在拥有的页脚示例:http://jsfiddle.net/CwXp4/

body {
background: url(http://i.imgur.com/R1yaNOy.png);
}

#footer {
position: absolute;
width: 100%;
height: 200px;
bottom: 0;
background-color: #333;
}

#footer:before {
content: "";
display: block;
position: relative;
top: -21px;
height: 21px;
background: linear-gradient( 45deg, #333 50%, transparent 50%) 0 0, linear-gradient(-45deg, #333 50%, transparent 50%) 0 0;
background-repeat: repeat-x;
background-size: 40px 40px, 40px 40px;
}
<div id="footer"></div>

有没有人给我一些关于如何添加阴影的提示?

最佳答案

您可以通过某种方式制作具有与制作之字形相同的渐变的阴影。

CSS

#footer:before {
content: "";
display: block;
position: relative;
top: -21px;
height: 22px;
background: linear-gradient( 45deg, #333 50%, blue 50%, transparent 55%) 0 0,
linear-gradient(-45deg, #333 50%, blue 50%, transparent 55%) 0 0;
background-repeat: repeat-x;
background-size: 40px 47px, 40px 47px;
}

body {
background: url(http://i.imgur.com/R1yaNOy.png);
}

#footer {
position: absolute;
width: 100%;
height: 200px;
bottom: 0;
background-color: #333;
}

#footer:before {
content: "";
display: block;
position: relative;
top: -21px;
height: 22px;
background: linear-gradient( 45deg, #333 50%, blue 50%, transparent 55%) 0 0, linear-gradient(-45deg, #333 50%, blue 50%, transparent 55%) 0 0;
background-repeat: repeat-x;
background-size: 40px 47px, 40px 47px;
}
<div id="footer"></div>

fiddle

您也可以使用 webkit-filter 阴影获得阴影,但这支持有限

CSS

#footer:before {
content: "";
display: block;
position: relative;
top: -21px;
height: 22px;
background: linear-gradient( 45deg, #333 50%, transparent 50%) 0 0,
linear-gradient(-45deg, #333 50%, transparent 50%) 0 0;

background-repeat: repeat-x;
background-size: 40px 47px, 40px 47px;
-webkit-filter: drop-shadow(red 0px -5px 5px);
}

body {
background: url(http://i.imgur.com/R1yaNOy.png);
}

#footer {
position: absolute;
width: 100%;
height: 200px;
bottom: 0;
background-color: #333;
}

#footer:before {
content: "";
display: block;
position: relative;
top: -21px;
height: 22px;
background: linear-gradient( 45deg, #333 50%, transparent 50%) 0 0, linear-gradient(-45deg, #333 50%, transparent 50%) 0 0;
background-repeat: repeat-x;
background-size: 40px 47px, 40px 47px;
-webkit-filter: drop-shadow(red 0px -5px 5px);
}
<div id="footer"></div>

fiddle with filter

关于html - 为 "zigzag"边框插入阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21515886/

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