简体   繁体   English

包装CSS3滑块

[英]Wrapping CSS3 Slider

Within this fiddle , I'm using CSS3 to slidein text (sample below). 在这个小提琴中 ,我正在使用CSS3滑动文本(下面的示例)。 However, I'd like it to wrap around to effectively implement a ticker. 但是,我希望它可以环绕起来以有效实现股票行情。 Though the problem seems to involve micro-managing pixels to both add more text and create a clean transition. 尽管问题似乎涉及微观管理像素,以添加更多文本并创建清晰的过渡。

@-webkit-keyframes slidein {
      from {
        margin-left:100%;
        width:100%
      }
      to {
        margin-left:0%;
        width:100%;
      }
    }

Advice? 忠告?

Here is an example , but I would like to use CSS. 这是一个示例 ,但我想使用CSS。

Booom your code here: SmoothTextFlow 在此处增加代码: SmoothTextFlow

     h1 {
      -webkit-animation-duration: 15s;
      -webkit-animation-name: slidein;
      -webkit-animation-iteration-count: infinite;
    -webkit-animation-timing-function: ease-in-out;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: graysc;
}

@-webkit-keyframes slidein {
      from {
        margin-left:100%;
        width:100%
      }
      to {
        margin-left:0%;
        width:100%;
      }
    }

This is one way to get it done: http://jsfiddle.net/ytKV5/ . 这是完成任务的一种方式: http : //jsfiddle.net/ytKV5/ Use Chrome. 使用Chrome。 I did not want to create code for every extension. 我不想为每个扩展创建代码。

Keep in mind that from CSS you cannot adjust the speed of the slide based on the length of the scrolling text. 请记住,在CSS中,您无法根据滚动文本的长度来调整幻灯片的速度。 The longer the text, the faster it'll scroll. 文字越长,滚动速度越快。

HTML: HTML:

<div id = "wrapper">
    <h1>Scrolling text....scrolling...scrolling</h1>
</div>

CSS: CSS:

* {
    margin: 0;
    padding: 0;
}

@-webkit-keyframes scroll-text {
    0% {
        left: 100%;
        -webkit-transform: translateX(0%);    
    }

    100% {
        left: 100%;
        -webkit-transform: translateX(-150%);  
    }
}

#wrapper {
    width: 200px;
    height: 40px;
    outline: 1px solid #000;
    margin: 0 auto;
    margin-top: 10px;
    position: relative;
    overflow: hidden;
}

#wrapper > h1 {
    white-space: nowrap;
    line-height: 40px;
    position: absolute;
    top: 0;
    -webkit-animation: scroll-text 15s linear infinite;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM