【问题标题】:CSS3 animation color with gradient带渐变的 CSS3 动画颜色
【发布时间】:2015-07-13 02:19:49
【问题描述】:

我正在使用 CSS3 动画将一个引导手风琴从一种颜色转换为其他颜色,但问题是我发现动画无法通过渐变进行过渡,而且手风琴对我来说似乎太多了 2D。 我读到人们做了一些技巧,比如将一个元素放在另一个元素上并使用不透明度,但在可能的情况下,将另一个元素设置在同一位置并不容易,因为它是动态创建的。

你能给我一些建议吗?

到目前为止,这是我尝试做的但没有成功:

.panel-warning > .panel-heading {
    background: linear-gradient(to bottom, #FCFCFC 0%, #FFF4C4 30%) repeat scroll 0 0 rgba(0, 0, 0, 0);
    opacity: 0;
}

.panel-warning > .panel-heading {
    -webkit-animation-direction: alternate;
    -webkit-animation-duration: 5s;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-name: alert-warning;
    -webkit-animation-timing-function: ease;
    -moz-animation-direction: alternate;
    -moz-animation-duration: 5s;
    -moz-animation-iteration-count: infinite;
    -moz-animation-name: alert-warning;
    -moz-animation-timing-function: ease;
    opacity: 0.5;
}

【问题讨论】:

  • 你能发布一个 jsfiddle 演示吗?
  • 很抱歉,因为HTML是由JSP动态创建的,所以非常复杂。
  • 显示问题和预期结果的最小示例将帮助我们了解您的要求

标签: css twitter-bootstrap


【解决方案1】:

虽然我同意其他人的观点,不清楚您究竟希望完成什么,但这里有一些简单的渐变动画演示代码:

.two:link, .two:visited {
  background: #2876b2;
  background: -webkit-linear-gradient(#2876b2, #549ad0);
  background: -moz-linear-gradient(#2876b2, #549ad0);
  background: -o-linear-gradient(#2876b2, #549ad0);
  background: linear-gradient(#2876b2, #549ad0);
  background-repeat: repeat;
  -webkit-background-size: 100% 200%;
  -moz-background-size: 100% 200%;
  background-size: 100% 200%;
  -webkit-transition: all .5s linear;
  -moz-transition: all .5s linear;
  -o-transition: all .5s linear;
  transition: all .5s linear;
}

.two:hover, .two:focus, .two:active {
  background-position: 0 -102%;
}

这适用于按钮,取自here

如果您追求更复杂的东西,您可能需要一些复杂的 JavaScript 黑客技术。

【讨论】:

  • 这里你只是在移动渐变。我正在做的是将动画从一种颜色移动到另一种颜色的循环。我昨天看到了这个演示。无论如何谢谢
【解决方案2】:

我猜你想要一个 css3 渐变动画,所以如果你使用这个网站的搜索,你可以找到这个问题,其中包含你问题的可能解决方案:

css3-animation-with-gradients

我最喜欢的解决方案是 Brian 的 http://jsfiddle.net/jSsZn/ CSS3

【讨论】:

  • 我认为在我的情况下使用该技术会很复杂,但谢谢!
猜你喜欢
  • 2012-11-25
  • 2011-08-05
  • 2012-06-13
  • 2017-06-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-03
  • 1970-01-01
相关资源
最近更新 更多