html - CSS Transition/Animation Prefix 问题

标签 html css animation browser

我正在尝试为客户推荐的幻灯片放映动画获取此 CSS 替代方案。我可以让它在 IE 和 Firefox 中运行,但在 Chrome 中无法运行。有人知道我是否需要使用一些前缀来解决这个问题吗?

这是一个Demo .

<div class="css-slideshow">
    <figure>
        <img src="http://www.offsetprinting.com/img/custom_images/test_slide1.jpg" alt="class-header-css3" width="1192" height="497" class="alignnone size-full wp-image-172" /><figcaption><strong>CSS3:</strong></figcaption> 
    </figure>
    <figure>
        <img src="http://www.offsetprinting.com/img/custom_images/test_slide2.jpg" alt="class-header-semantics" width="1192" height="497" class="alignnone size-full wp-image-179" /><figcaption><strong>Semantics:</strong></figcaption> 
    </figure>
    <figure>
        <img src="http://www.offsetprinting.com/img/custom_images/test_slide3.jpg" alt="class-header-offline" width="1192" height="497" class="alignnone size-large wp-image-178" /><figcaption><strong>Offline &amp; Storage:</strong></figcaption> 
    </figure>
    <figure>
        <img src="http://www.offsetprinting.com/img/custom_images/test_slide1.jpg" alt="class-header-device" width="1192" height="497" class="alignnone size-full wp-image-177" /><figcaption><strong>Device Access:</strong></figcaption> 
    </figure>
<figure>
        <img src="http://www.offsetprinting.com/img/custom_images/test_slide2.jpg" alt="class-header-connectivity" width="1192" height="497" class="alignnone size-large wp-image-176" /><figcaption><strong>Connectivity:</strong></figcaption> 
    </figure>
    <figure>
        <img src="http://www.offsetprinting.com/img/custom_images/test_slide3.jpg" alt="class-header-multimedia" width="1192" height="497" class="alignnone size-large wp-image-175" /><figcaption><strong>Multimedia:</strong></figcaption> 
    </figure>
    <figure>
        <img src="http://www.offsetprinting.com/img/custom_images/test_slide1.jpg" alt="class-header-3d" width="1192" height="497" class="alignnone size-large wp-image-174" /><figcaption><strong>3D, Graphics &amp; Effects:</strong></figcaption> 
    </figure>
    <figure>
        <img src="http://www.offsetprinting.com/img/custom_images/test_slide2.jpg" alt="class-header-performance" width="1192" height="497" class="alignnone size-large wp-image-173" /><figcaption><strong>Performance &amp; Integration:</strong></figcaption> 
    </figure>
  </div>  


body{
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; 
  font-weight: 300;
}
.css-slideshow{
  position: relative;
  max-width: 1192px;
  height: 497px;
  margin: 5em auto .5em auto;
}
.css-slideshow figure{
  margin: 0;
  max-width: 1192px;
  height: 497px;
  background: #000;
  position: absolute;
}
.css-slideshow img{
  box-shadow: 0 0 2px #666;
}
.css-slideshow figcaption{
  position: absolute;
  top: 0;
  color: #fff;
  background: rgba(0,0,0, .3);
  font-size: .8em;
  padding: 8px 12px;
  opacity: 0;
  transition: opacity .5s;
}

.css-slideshow-attr{
  max-width: 1192px;
  text-align: right;
  font-size: .7em;
  font-style: italic;
  margin:0 auto;
}
.css-slideshow-attr a{
  color: #666;
}
.css-slideshow figure{
  opacity:0;
}
figure:nth-child(1) {
  animation: xfade 48s 42s infinite;
}
figure:nth-child(2) {
  animation: xfade 48s 36s infinite;
}
figure:nth-child(3) {
  animation: xfade 48s 30s infinite;
}
figure:nth-child(4) {
  animation: xfade 48s 24s infinite;
}
figure:nth-child(5) {
  animation: xfade 48s 18s infinite;
}
figure:nth-child(6) {
  animation: xfade 48s 12s infinite;
}
figure:nth-child(7) {
  animation: xfade 48s 6s infinite;
}
figure:nth-child(8) {
  animation: xfade 48s 0s infinite;
}

@keyframes xfade{
  0%{
    opacity: 1;
  }
  10.5% {
    opacity: 1;
  }
  12.5%{
    opacity: 0;
  }
  98% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
</

最佳答案

Chrome 是一个 webkit 浏览器,尝试像这样使用 webkit 前缀(http://www.w3schools.com/cssref/css3_pr_animation-keyframes.asp):

figure:nth-child(8) {
    animation: xfade 48s 0s infinite;
    -webkit-animation: xfade 48s 0s infinite;
}

@-webkit-keyframes xfade{
  0%{
    opacity: 1;
  }
  10.5% {
    opacity: 1;
  }
  12.5%{
    opacity: 0;
  }
  98% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes xfade{
  0%{
    opacity: 1;
  }
  10.5% {
    opacity: 1;
  }
  12.5%{
    opacity: 0;
  }
  98% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

关于html - CSS Transition/Animation Prefix 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30406997/

相关文章:

javascript - 尝试向我的 jquery 幻灯片添加额外的标题动画

Java Swing 处理状态

ios - UIView.animateWithDuration 在 UITableviewCell 中不起作用

html - 如何同时拥有水平和垂直导航栏

html - super 菜单如何改变方向?

html - CSS 透明 1x1 黑色像素,不透明?

html - 在 100% 宽度的 div 上创建内部面板需要什么 CSS

html - flex 盒内图像的缩放效果

HTML/CSS 链接滚动不滚动到正确的位置