首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >动画内联元素全宽滚动

动画内联元素全宽滚动
EN

Stack Overflow用户
提问于 2013-08-01 14:09:33
回答 1查看 490关注 0票数 0

对于下面的段落,我想要在鼠标悬停时以动画方式滚动span元素。它将向右滚动,直到结束。

代码语言:javascript
复制
  <div class="one_line">
    <span>
        NoMagic framework doesn't try to put anything into the blackbox. We hope you read the core source code and try to get fully understanding before you start to using it. And we hope you forking our project and creating your own database helper function sets based on your need.

        Using NoMagic, you will turn the MySQL database into a schemaless solution, the schemaless database will save your time so that you don't need to spend to much time in planning database table structure.
    </span>
  </div>

我已经拥有的css

代码语言:javascript
复制
.one_line {
  line-height: 1.5em;
  height: 1.5em;
  position: relative;
  width: 600px;
  overflow-x: hidden;
  span {
    white-space: nowrap;
    height: 100%;
    display: inline-block;
    position: absolute;
    &:hover {
      animation-name: scroll;
      animation-duration: 6s;
    } 
  }
}

@keyframes scroll {
  50% {
    left: 100%;
  }
}
EN

回答 1

Stack Overflow用户

发布于 2013-08-02 22:59:00

据我所知,使用CSS动画,我们只能动画整个标签本身,而不是它的内容(即)在这种情况下,我们可以在页面维度上移动整个跨度,但不能移动其中的文本。所以我使用了transform属性,它更灵活。

我有一个jsfiddle here来演示这一点。

CSS动画代码,我已经改变了:

代码语言:javascript
复制
@keyframes scroll { 
   0%   {  
         transform:translateX(0);  
        }  
   100% {  
         transform:translateX(-100%);  
        }
}

希望这将是有用的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17986359

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档