将鼠标悬停在暂停选取框上
我想创建一个滚动一些新闻文章的选框,但是当用户将鼠标悬停在它上面时,我需要它暂停,当用户将鼠标悬停在它外面(onMouseOut)时,我需要它启动备份。这不起作用:
<marquee onMouseOver="this.stop()" onMouseOut="this.start()">Text</marquee>
有人对如何用最少的代码实现这一目标有任何建议吗?
I want to create a Marquee that scrolls some news articles but when the user hovers over it I need it to pause and when the user hovers out of it (onMouseOut) I need it to start back up. This did not work:
<marquee onMouseOver="this.stop()" onMouseOut="this.start()">Text</marquee>
Does anyone have any suggestions on how I can achieve this in a minimal amount of code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
您使用了错误的大小写:onMouseOver、onMouseOut
You're using wrong case: onMouseOver,onMouseOut
marquee 标签有一个名为
scrollmount
的属性,它控制它的运行速度。我们需要做的就是当鼠标悬停时将值设置为0
,并在鼠标移出时将其设置回5
。演示:http://jsfiddle.net/U9yFj/
The marquee tag has an attribute called
scrollamount
which controls how fast it goes. All we need to do is set the value to0
when we hover in and set it back to5
when we mouse out.DEMO: http://jsfiddle.net/U9yFj/
希望这段代码对使用 MARQUEE 标签的人有所帮助。
Hope this code will help someone who is use MARQUEE tag.
您可以简单地使用 HTML 选取框标记,
然后是
You can simply use the HTML marquee markup with
followed by
关闭
()
后,您必须将;
添加到代码中。You have to add
;
to your code after closing the()
.虽然 onmouseover 和 onmouseout 函数可能在某些浏览器上工作。
请注意,字幕标记已过时,可能已失效。
在这个语义html时代,我们应该使用html来构建内容。 CSS 应该用于视觉样式,如果需要,CSS 应该由 Javascript 提供支持。
CSS3 实现字幕效果的方式。
Although the onmouseover and onmouseout function may work on some browser.
Please note that marquee tag is outdated and can say dead.
In this era of semantic html we should use html to structure content. CSS should be sued for Visual styling and if required the CSS should be powered by Javascript.
CSS3 way of achieving marquee affect.