当前位置:软件学堂 > 资讯首页 > 网络编程 > 编程其他 > 使用marquee实现文字上下滚动

使用marquee实现文字上下滚动

2012/10/22 19:48:24作者:佚名来源:网络

移动端

【实例名称】

使用marquee实现文字上下滚动

【实例描述】

文字滚动可以通过定时器实现,也可以使用HTML中的marquee元素实现.本例介绍后者的使用情况。

【实例代码】

   

<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> </head> <body>

<marquee direction=up scrollamount=1 scrolldelay=100 onmouseover='this.stop()' onmouseout='this.start()' height=60> <table> <tr> <td> 这是第一行第一列 </td> </tr> <tr> <td> 这是第二行第一列 </td> </tr> <tr> <td> 这是第三行第一列 </td></tr> </table> </marquee> </body> </html>

【运行效果】

运行效果

【难点剖析】

本例的难点是对marquee元素的控制。滚动控件通常具备两个功能:鼠标经过停止和鼠标移走继续。这里通过marquee元素的事件“onmouseover”“onmouseout”完成这两个功能。“stop”和“start”方法用来控制marquee是否滚动。

【源码下载】

本实例JS代码下载

 

标签: 文字