Javascript 如何创建新闻自动收报机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12349985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a news ticker
提问by user1658756
I'd like to have a news ticker that scrolls from right to left that is easy to add a delete items.
我想要一个从右向左滚动的新闻自动收报机,可以轻松添加删除项目。
It'd be ideal if I could use jQuery or raw JavaScript if I have to.
如果必须的话,如果我可以使用 jQuery 或原始 JavaScript,那将是理想的。
Is there a jQuery plugin or a way I can get a news ticker?
是否有 jQuery 插件或获取新闻行情的方法?
After research, I've noticed that a lot of them scroll from top to bottom and not from right to left.
经过研究,我注意到其中很多是从上到下滚动的,而不是从右到左滚动。
The point of the news ticker is that it's easy to add or remove items, and when you hover, the ticker stops and then resumes when the mouse is not over it.
新闻自动收报机的重点是添加或删除项目很容易,当您悬停时,自动收报机停止,然后在鼠标不在其上方时恢复。
Update
更新
I've just found liScroll - http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html
我刚刚找到 liScroll - http://www.gcmingati.net/wordpress/wp-content/lab/jquery/newsticker/jq-liscroll/scrollanimate.html
http://htmlmarquee.com/looks pretty good too
http://htmlmarquee.com/看起来也不错
回答by mtk
If you need a functionality like a Ticker, maybe Left to Right or Top to Bottom, you could simple use the html marquee
tag. Use javascriptor jqueryto update it's content dynamically as you feed comfortable.
如果您需要像 Ticker 这样的功能,可能是从左到右或从上到下,您可以简单地使用 htmlmarquee
标签。使用javascript或jquery动态更新它的内容,因为您感到舒适。
You can also alter its motion behavior with onmouseover
and onmouseout
events, like
您还可以使用onmouseover
和onmouseout
事件更改其运动行为,例如
<marquee behavior="scroll" direction="right"
onmouseover="this.stop();"
onmouseout="this.start();">
Hover to stop!
</marquee>
You can play with this at htmlmarquee.com. Check it.
You can see other available options for motion control here.
你可以在htmlmarquee.com 上玩这个。核实。
您可以在此处查看其他可用的运动控制选项。
回答by I'm with Monica
Though the <marquee>
-element, as suggested by mtk, will work in most browsers, it is not standard HTML and should not be used, if standards-compliance is an issue. You should then use the appropriate CSS-styles!
尽管<marquee>
mtk 建议的 -element 可以在大多数浏览器中使用,但它不是标准的 HTML,如果不符合标准,则不应使用。然后你应该使用适当的 CSS样式!
You can then put your content in almost any HTML-element and just "marquee" it around as you like.
然后,您可以将您的内容放在几乎任何 HTML 元素中,然后根据需要将其“选中”。
回答by codebox
Have you tried jQuery News Ticker?
你试过jQuery News Ticker吗?