【问题标题】:inset shadow for "zigzag" border“之字形”边框的嵌入阴影
【发布时间】:2014-02-02 20:36:00
【问题描述】:

我目前正在设计一个网站,对于页脚,我在顶部创建了一个“之字形”边框。 为了在网站中创建一些深度,我想在“之字形”中的三角​​形上添加阴影,这就是我目前卡住的地方。

这是我现在拥有的页脚示例: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 很陌生。我尝试的是普通的盒子阴影,但它只是放在三角形下面,就像这样jsfiddle.net/Ynxu3

标签: html footer css dropshadow


【解决方案1】:

您可以以某种方式使用与用于制作锯齿形的相同渐变来制作阴影。

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

【讨论】:

  • 感谢您的回复,这或多或少是我想要的。 jsfiddle.net/CwXp4/5。您将如何使用这个 webkit-filter 来比较这两个选项?
  • 添加了使用过滤器的示例。效果不太好,具体原因我也不知道。它只适用于 webkit。
猜你喜欢
  • 2018-08-29
  • 2012-03-26
  • 1970-01-01
  • 2017-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多