CSS/JQuery powered sideways scrolling text on hover

后端 未结 6 1396
醉话见心
醉话见心 2021-02-06 04:03

I have a twitter feed on a website I run. However, it gets cut off on small screens. I have a bar tall enough for 1 line of text in which I have the latest tweet. I want the twe

6条回答
  •  悲&欢浪女
    2021-02-06 04:46

    There are a few plugins out there that do this (Remy Sharp: http://remysharp.com/demo/marquee.html for example), but if you were building from scratch:

    The item being scrolled needs to have "white-space: nowrap;" (to keep it on one line), "position:absolute" (to allow it scroll left and right) and wrapped in a relatively positioned element that has "overflow:hidden" (to make it appear like only the width you want shows).

    Using jQuery, you could use .animate() to move the scroll item from left to right on the hover event

提交回复
热议问题