项目经历——Marquee,HTML中一个有趣的标签

来源:互联网 发布:图书管理系统数据库sql 编辑:程序博客网 时间:2024/05/04 18:16

  在善良公社项目中,客户要求在主界面中,实现新注册的用户要滚动显示的效果,偶然间了解到了<marquee>标签。兴趣使然,这里来共同学习一下该标签。

基本作用

  该标签是个容器标签,主要功能是实现滚动字幕的效果。

  语法:<marquee></marquee>

常用事件

  onMouseOut="this.start()" :鼠标移除标签区域的时候,标签开始滚动;

  onMouseOver="this.stop()":鼠标移动到标签上的时候,标签停止滚动; 

常用属性

  align:设定<marquee>标签内容的对齐方式

    absbottom:绝对底部对齐(与g、p等字母的最下端对齐)
    absmiddle:绝对中央对齐
    baseline:底线对齐
    bottom:底部对齐(默认)
    left:左对齐
    middle:中间对齐
    right:右对齐
    texttop:顶线对齐

    top:顶部对齐


  behavior:设定滚动的方式:

    alternate: 表示在两端之间来回滚动。
    scroll: 表示由一端滚动到另一端,会重复。

    slide:  表示由一端滚动到另一端,不会重复。

<marquee behavior="alternate">alternate:表示在两端之间来回滚动。 </marquee><marquee behavior="scroll">scroll:表示由一端滚动到另一端,会重复。</marquee><marquee behavior="slide">slide:  表示由一端滚动到另一端,不会重复。</marquee>


  bgcolor:设定活动字幕的背景颜色,背景颜色可用RGB、16进制值的格式或颜色名称来设定

  

<marquee bgcolor="#006699">设定活动字幕的背景颜色 bgcolor="#006699"</marquee><marquee bgcolor="RGB(10%,50%,100%,)">设定活动字幕的背景颜色 bgcolor="rgb(10%,50%,100%,)"</marquee><marquee bgcolor="red">设定活动字幕的背景颜色 bgcolor="red"</marquee>


  direction:设定活动字幕的滚动方向


<marquee direction="down">设定活动字幕的滚动方向direction="down":向下</marquee><marquee direction="left">设定活动字幕的滚动方向direction="left":向左</marquee><marquee direction="right">设定活动字幕的滚动方向direction="right":向右</marquee><marquee direction="up">设定活动字幕的滚动方向direction="up":向上</marquee>


  loop:设定滚动的次数,当loop=-1表示一直滚动下去,默认为-1;如果设置具体数值,表示只滚动对应的次数

<marquee loop="-1" bgcolor="#CCCCCC">这个标签不停的循环</marquee><marquee loop="2" bgcolor="#CCCCCC">这个标签循环两次之后就不显示了</marquee>


  scrollamount:设定活动字幕的滚动速度,单位pixels


<marquee scrollamount="10" >滚动速度为"10" </marquee><marquee scrollamount="20" >滚动速度为"20" </marquee><marquee scrollamount="30" >滚动速度为"30" </marquee>


  scrolldelay:设定活动字幕滚动两次之间的延迟时间,单位millisecond(毫秒)值大了会有一步一停顿的效果

<marquee scrolldelay="10" >scrolldelay="10" </marquee><marquee scrolldelay="100" > scrolldelay="100"</marquee><marquee scrolldelay="1000">scrolldelay="1000" </marquee>

项目实践:

<marquee onmouseover="this.stop()" onmouseout="this.start()" scrollamount="1" vspace="5" scrolldelay="60" direction="up" behavior="scroll" width="95%" height="120">                        <table style="color:#184C7E;font-size:12px;width:100%;">                            <tr>                                <td><a href="#">王红</a> </td>                                <td>女</td>                                <td>12岁</td>                                <td>青海</td>                                <td>学生</td>                            </tr>                                                      <tr>                                <td>王红</td>                                <td>女</td>                                <td>12岁</td>                                <td>青海</td>                                <td>学生</td>                            </tr>                                                      <tr>                                <td>王红</td>                                <td>女</td>                                <td>12岁</td>                                <td>青海</td>                                <td>学生</td>                            </tr>                            <tr>                                <td>王红</td>                                <td>女</td>                                <td>12岁</td>                                <td>青海</td>                                <td>学生</td>                            </tr>                                                  </table></marquee>