关于html:marquee属性的详解

来源:互联网 发布:国债逆回购软件 编辑:程序博客网 时间:2024/06/10 05:50

                                                 <marquee>标签


          <marquee>标签是成对出现的标签,首标签<marquee>和尾标签</marquee>之间的内容就是滚动内容。

         <marquee>标签的属性主要有behaviorbgcolordirectionwidthheighthspacevspaceloopscrollamountscrolldelay等,它们都是可选的。


一.  behavior属性


         behavior属性的参数值为alternatescrollslide中的一个,分别表示文字来回滚动、单方向循环滚动、只滚动一次,需要注意的是:如果在<marquee>标签中同时出现了directionbehavior属性,那么scrollslide的滚动方向将依照direction属性中参数的设置。

<marquee behavior="alternate">我来回滚动</marquee>

<marquee behavior="scroll">我单方向循环滚动</marquee><marquee behavior="scroll" direction="up" height="30">我改单方向向上循环滚动</marquee> <marquee behavior="slide">我只滚动一次</marquee>

<marquee behavior="slide" direction="up">我改向上只滚动一次了</marquee>

bgcolor属性文字滚动范围的背景颜色,参数值是16进制(形式:#AABBCC#AA5566等)或预定义的颜色名字(如redyellowblue等)。如下所示:<marquee behavior=="slide" direction="left" bgcolor="red">我的背景色是红色的</marquee>



 二.direction属性


  文字滚动的方向,属性的参数值有downleftrightup共四个单一可选值,分别代表滚动方向向下、向左、向右、向上。如下所示:

<marquee direction="right">我向右滚动</marquee>

<marquee direction="right">我向下滚动</marquee>

三.widthheight属性


  widthheight属性的作用决定滚动文字在页面中的矩形范围大小。width属性用以规定矩形的宽度,height属性规定矩形的高度。这两个属性的参数值可以是数字或者百分数,数字表示矩形所占的(宽或高)像素点数,百分数表示矩形所占浏览器窗口的(宽或高)百分比。如下所示:

  <marquee width="300" height="30" bgcolor="red">我宽300像素,高30像素。</marquee>
hspacevspace属性

  这两个属性决定滚动矩形区域距周围的空白区域.

<marquee width="300" height="30" vspace="10" hspace="10" bgcolor="red">我矩形边缘水平和垂直距周围各10像素。</marquee>


<marquee width="300" height="30" vspace="50" hspace="50" bgcolor="red">我矩形边缘水平和垂直距周围各50像素。</marquee>


四.loop属性


  loop属性决定滚动文字的滚动次数,缺省是无限循环。参数值可以是任意的正整数,如果设置参数值为-1infinite时将无限循环。如下所示:

  <marquee loop="2">我滚动2次。</marquee>

<marquee loop="infinite">我无限循环滚动。</marquee>


<marquee loop="-1">我无限循环滚动。</marquee>


五.scrollamountscrolldelay属性


  这两个属性决定文字滚动的速度(scrollamount)和延时(scrolldelay),参数值都是正整数。如下所示:

<marquee scrollamount="100">我速度很快.</marquee>


<marquee scrollamount="50">我慢了些。</marquee>

<marquee scrolldelay="30">我小步前进。</marquee>

<marquee scrolldelay="1000" scrollamount="100">我大步前进。</marquee>

 

最后说一下align属性,这个属性决定滚动文字位于距形内边框的上下左右位置。您也可以将<marquee></marquee>之间的内容替换为图像或其它对象等

<marquee direction="down" behavior="alternate" height="185">sdsdsd</marquee></p>

<body onselectstart="return false" bgcolor="#F5F5F5"> 

<div id="marquees"> 

<table width="175" height="80" border="0"> 

<tr> 

<td height="80"><a href="about.aspx" target="_blank" class="linkslan">我公司是全国机械工业标准化委员会"应变与振动仪器设备"国家标准工作组组长单位,主导并参与制定行业标准,保持多年业界技术领先地位。本公司视"不断创新"做为保持核心竞争力的关键,核心团队在业界经营近"四十年",7V系列产品早已成为我国工程检测界知名品牌,我方产品已成功用于神五发射架,太空舱,秦山核电二期,多座长江大桥,鞍钢新一号高炉等诸多重要工程检测应用中<br> 
  静态数据采集7V系列产品,虚拟仪器技术,以太网动态工业测控DAQ系列产品,新兴Zigbee技术,无线个人局域网WDAQ系列产品,全球率先推出的WDAQ1002/3型长期在线,应变信号智能传感器无线网络产品,为工业自动化,工业检测界,衡器等产品升级和技术创新提供OEM方式合作良机</a></td> 
</tr> 
</table> 
</div> 
<script language="JavaScript"> 
marqueesHeight=100; 
stopscroll=false; 
with(marquees){ 
style.width=0; 
style.height=marqueesHeight; 
style.overflowX="visible"; 
style.overflowY="hidden"; 
noWrap=true; 
onmouseover=new Function("stopscroll=true"); 
onmouseout=new Function("stopscroll=false"); 

document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>'); 

preTop=0; currentTop=0; 

function init(){ 
templayer.innerHTML=""; 
while(templayer.offsetHeight<marqueesHeight){ 
templayer.innerHTML+=marquees.innerHTML; 

marquees.innerHTML=templayer.innerHTML+templayer.innerHTML; 
setInterval("scrollUp()",40);//越大越慢 

document.body.onload=init; 

function scrollUp(){ 
if(stopscroll==true) return; 
preTop=marquees.scrollTop; 
marquees.scrollTop+=1; 
if(preTop==marquees.scrollTop){ 
marquees.scrollTop=templayer.offsetHeight-marqueesHeight; 
marquees.scrollTop+=1; 


</script>

<marquee direction="right">向右滚动</marquee> 

<marquee direction="down">向下滚动</marquee>


<marquee direction="left">向左滚动</marquee> 

<marquee direction="right">向上滚动</marquee>

 

0 0
原创粉丝点击