当前位置:首页 > 网站应用

js实现公告文字标题无缝向上滚动特效

cjw1233年前 (2023-11-01)网站应用5410
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<TITLE>无间隙文字向上滚动特效</TITLE>
<style type="text/css">
ul {
 padding-right: 0px;
 padding-left: 0px;
 padding-bottom: 0px;
 margin: 0px;
 padding-top: 0px
}
#net {
 width:100%;
 background:url(img/menu_bg.gif) repeat;
 overflow: hidden;
}
#net div {
 border: #e6e6e6 1px solid;
 padding:0px 10px 0px 10px;
 overflow-y:hidden;
 line-height: 24px;
 height: 24px
}
#net li {
 font-size: 12px;
 float: left;
 list-style-type: none;
 margin-right: 20px;
 padding-left: 10px;
 background: url() no-repeat 0px 50%;
 white-space: nowrap
}
#net a {
 text-decoration: none;
}
#net a:hover {
 text-decoration:underline;
}
</style>
</HEAD>
<BODY>
<DIV id=net onMouseOver="if(!anncount) {clearTimeout(annst);annst = 0}" onMouseOut="if(!annst) annst = setTimeout('mainDo()', anndelay);">
  <DIV id=w_net>
    <UL>
      <li><a href="#" target="_blank">滚动新闻1号</a></li>
      <li><a href="#" target="_blank">滚动公告2号</a></li>
      <li><a href="#" target="_blank">滚动公告3号</a></li>
      <li><a href="#" target="_blank">滚动公告4号</a></li>
      <li><a href="#" target="_blank">滚动公告5号</a></li>
    </UL>
  </DIV>
</DIV>
<script type="text/javascript">
function $(id){
   return document.getElementById(id);
}
var anndelay = 3000;
var anncount = 0;
var annheight = 24;
var annst = 0;
function mainDo(){
   if(!annst){
      $('w_net').innerHTML += '<br style="clear: both" />' + $('w_net').innerHTML;
      $('w_net').scrollTop = 0;
      if($('w_net').scrollHeight > annheight * 3){
         annst = setTimeout('mainDo()', anndelay);
      }else{
         $('net').onmouseover = $('net').onmouseout = null;
      }
      return;
   }
   if(anncount == annheight){
      if($('w_net').scrollHeight - annheight <= $('w_net').scrollTop){
         $('w_net').scrollTop = $('w_net').scrollHeight / 2 - annheight;
      }
      anncount = 0;
      annst = setTimeout('mainDo()', anndelay);
   }else{
      $('w_net').scrollTop ++ ;
      anncount ++ ;
      annst = setTimeout('mainDo()', 10);
   }
}
mainDo();
</script>
</BODY>
</HTML>


扫描二维码推送至手机访问。

版权声明:本文由追求完美发布,如需转载请注明出处。

本文链接:https://cjw123.com/blog/?id=42

标签: htmljscss
分享给朋友:

相关文章

html meta标签屏蔽搜索引擎的用法

html页面中的 meta 标签可以用来识别搜索引擎的蜘蛛类型,可以规定meta标签所在的html页面是否被蜘蛛抓取,下面是这个meta标签的用法,大家可以借鉴一下。搜索引擎的 meta 标签的解析下面是meta标签对搜索引擎的解析<meta name='robot…

js实现鼠标经过列表弹出提示层效果

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <t…

一个网站网页快照截图的接口

如果您的网站想展示某个网站的快照截图的话使用这个网页快照截图的接口确实比较方便网页快照截图接口使用https://s0.wp.com/mshots/v1/网址?w=宽度&h=高度示例https://s0.wp.com/mshots/v1/www.cjw123.com?w=1900&h…

纯CSS实现菜单炫酷点击展开收起效果

通过纯css3实现展开收缩的弹性动画菜单,可以应用于PC端或移动端页面中,非常实用效果也非常的炫酷,喜欢的码友们可以尝试一下,效果如下:完整代码如下:<!doctype html><html><head><meta charset=&qu…

网站js防扒代码-禁止右键/F12/调试自动关闭窗口

非常暴力。宣称可以禁用所有一切可以进入开发者工具的方法,防止通过开发者工具进行的 "代码搬运"1.效果演示演示站以及原文地址:https://theajack.github.io/disable-devtool/说明:此法较为非常j狠。宣称可以禁用所有一切可以进入开发者工具的方法…

霓虹灯文字代码

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title&g…

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。