html - 如何在不使用选取框的情况下使用 CSS 从右到左创建移动背景?

标签 html css

我想在标题中创建一个背景,它应该不断地从右到左移动,图片应该自己重复。我不想在这里使用 javascript。

最佳答案

为此使用 css3 动画

它们使用起来非常简单

.hi {
    width: 50px;
    height: 72px;
    background-image: url("http://files.simurai.com/misc/sprite.png");

    -webkit-animation: play .8s steps(10) infinite;
       -moz-animation: play .8s steps(10) infinite;
        -ms-animation: play .8s steps(10) infinite;
         -o-animation: play .8s steps(10) infinite;
            animation: play .8s steps(10) infinite;
}

@-webkit-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@-moz-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@-ms-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@-o-keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}

@keyframes play {
   from { background-position:    0px; }
     to { background-position: -500px; }
}


<img src="http://files.simurai.com/misc/sprite.png" />
<div class="hi"></div>

http://jsfiddle.net/simurai/CGmCe/light/

关于html - 如何在不使用选取框的情况下使用 CSS 从右到左创建移动背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17766658/

相关文章:

html - Bootstrap 下拉列表中的表格

javascript - 在隐藏和显示元素时添加微妙的动画 -CSS -JS

html 日期格式 yyyy mm dd hh24 mi ss 作为 HTML 中的输入类型

javascript - 如何通过jQuery上传图片?

html - 倾斜的侧边栏布局

html - 简单的页脚问题

html - Internet Explorer 网站顶部的额外空间

javascript - 为什么启用和禁用按钮不起作用?

html - CSS 列显示不正确

html - 将正文放在一栏中,图像放在单独的右栏中