admin管理员组文章数量:1353641
I want to build a scrolling ticker on the bottom of the screen that scrolls right to left.
What is the best way to approach this? I'm using reactjs, and I read that react doesn't play well with jQuery, and most of the examples I've found, use jQuery.
I want to build a scrolling ticker on the bottom of the screen that scrolls right to left.
What is the best way to approach this? I'm using reactjs, and I read that react doesn't play well with jQuery, and most of the examples I've found, use jQuery.
Share Improve this question edited Dec 8, 2015 at 13:40 Peter O. 32.9k14 gold badges85 silver badges97 bronze badges asked Dec 7, 2015 at 23:17 clarityclarity 4411 gold badge9 silver badges19 bronze badges 4- Have you tried anything? – Kyeotic Commented Dec 7, 2015 at 23:24
- I've tried googling around, but I can't seem to find anything that's not heavily using jquery – clarity Commented Dec 7, 2015 at 23:25
- Would a CSS solution work? – Kyeotic Commented Dec 7, 2015 at 23:32
- If there is a pure css solution, I'd be happy to use it! – clarity Commented Dec 7, 2015 at 23:36
3 Answers
Reset to default 8You can create a side-scrolling effect purely with css. Here is a demo fiddle.
/* Make it a marquee */
.marquee {
margin: 0 auto;
white-space: nowrap;
overflow: hidden;
}
.marquee span {
display: inline-block;
padding-left: 100%;
animation: marquee 5s linear infinite;
}
/* Make it move */
@keyframes marquee {
0% { transform: translate(0, 0); }
100% { transform: translate(-100%, 0); }
}
Based on
Tyrsius
solution, I have modified a little bit the keyframe animation, so now it will stop for a while in the middle of the way, so user can read the content in a confortable way:
@keyframes marquee {
0% { transform: translate(0,0);
font-style:italic;
opacity:0;}
5% { opacity:0;}
14% { opacity:0.8;}
15% { transform: translate(-46%, 0);
opacity:1;
font-style:normal;}
85% { transform: translate(-54%, 0);
opacity:1;
font-style:normal;}
86% { opacity:0.8;}
96% { opacity:0;}
100% { transform: translate(-100%, 0);
opacity:0;}}
Check out the react-scroll directive:
https://www.npmjs./package/react-scroll
本文标签: javascriptScrolling div tickerStack Overflow
版权声明:本文标题:javascript - Scrolling div ticker - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743933563a2564281.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论