【问题标题】:Continous x-axis background-image slide连续 x 轴背景图像幻灯片
【发布时间】:2012-11-08 17:03:29
【问题描述】:

我有一个带有大图背景 css 规则的 div 元素。

现在想在x轴平滑滑动图片,有没有轻量级的插件或者sn-p?

欢迎提出任何建议!

【问题讨论】:

  • 完全不清楚...你只是想水平重复相同的图像吗?
  • 不,我想让它在背景中向左滑动,它只是重复 css 规则的原因 background-repeat:repeat-x;我只需要让它在左方向和 x 轴上连续移动
  • 喜欢这个? jsbin.com/uzifag/1
  • 是的,但我看不到它在移动.. 奇怪

标签: javascript jquery css loops slide


【解决方案1】:

这是 webkit 的样式:http://jsbin.com/uzifag/2/

请注意,我将背景位置移动到图像的负宽度。如果您希望它是相反的方向,则正宽度将起作用。您可以根据需要播放动画的持续时间。

body{
  background:url(http://placekitten.com/1920/1080/) repeat-x center left;
  -webkit-animation: slidex 20s linear infinite;
     -moz-animation: slidex 20s linear infinite;
      -ms-animation: slidex 20s linear infinite;
       -o-animation: slidex 20s linear infinite;
          animation: slidex 20s linear infinite;
}

@-webkit-keyframes slidex
{
  FROM{background-position:0 center;}
  TO{background-position:-1920px center;}
}
@-moz-keyframes slidex
{
  FROM{background-position:0 center;}
  TO{background-position:-1920px center;}
}
@-ms-keyframes slidex
{
  FROM{background-position:0 center;}
  TO{background-position:-1920px center;}
}
@-o-keyframes slidex
{
  FROM{background-position:0 center;}
  TO{background-position:-1920px center;}
}
@keyframes slidex
{
  FROM{background-position:0 center;}
  TO{background-position:-1920px center;}
}

【讨论】:

  • 我在 FF 它不动:P
  • 您需要为每个供应商添加关键帧和动画定义:-moz-、-ms-、-o-、-webkit-
  • 你看到左边移动了吗?我看不出这很奇怪:/认为这是我的问题
  • 啊,好的,请在您的 css3 中添加完整的浏览器支持 (moz,o,ms),以便我可以将其设置为已选中;)
  • 我相信只有 IE10 支持 CSS3 动画。 Safari 应该可以正常工作。
猜你喜欢
  • 1970-01-01
  • 2011-03-26
  • 1970-01-01
  • 2012-08-04
  • 2014-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多