1.     <div class="inform" style="">
  2. <div style="height:35px; overflow:hidden;">
  3. <ul id="marquee" style="height:35px;">
                <li><a href="javascript:void(0)" style="display:inline-block;overflow: hidden; white-space: nowrap;text-overflow:ellipsis; width: 100%;">****已预订****</a></li>
  1.              <li><a href="javascript:void(0)" style="display:inline-block;overflow: hidden; white-space: nowrap;text-overflow:ellipsis; width: 100%;">
  2. ****已预订****</a></li>
  1.           </ul>
  2. </div>
  3.  
  4. <script type="text/javascript">
  5. var liHeight = $('#marquee li').eq(0).outerHeight();
  6. //$('#marquee').css('height',liHeight * $('#marquee li').length * 2);
  7. setTimeout("startmarquee("+ liHeight +", 50, 500, 'marquee')", 500);
  8. function startmarquee(lh,speed,delay,id) {
  9. var t;
  10. var p = false;
  11. var o = document.getElementById(id);
  12. o.innerHTML += o.innerHTML;
  13. o.onmouseover = function() {
  14. p = true;
  15. }
  16. o.onmouseout = function() {
  17. p = false;
  18. }
  19. o.scrollTop = 0;
  20.  
  21. function start() {
  22. t = setInterval(scrolling,speed);
  23. if(!p) o.scrollTop += 1;
  24. }
  25.  
  26. function scrolling() {
  27. if(o.scrollTop%lh != 0) {
  28. o.scrollTop += 1;
  29. if(o.scrollTop >= o.scrollHeight / 2) o.scrollTop = 0;
  30. } else {
  31. clearInterval(t);
  32. setTimeout(start,delay);
  33. }
  34. }
  35. setTimeout(start,delay);
  36. }
  37. </script>
  38. </div>

css:

  1. .inform {
  2. padding: 1px;
  3. margin: 10px auto;
  4. /*position: fixed; bottom:80px;left: 50%;*/ width: 6.8rem;font-size: 12px;/*margin-left: -3.4rem;*/ border: none; background-color:rgba(238,115,115,0.3); border-radius: 10px;
  5. }
  6. .inform h2 {
  7. background: none repeat scroll 0 0 #015198;
  8. font-weight: normal;
  9. line-height: 30px;
  10. }
  11. .inform h2 span {
  12. color: #FFFFFF;
  13. font-size: 16px;
  14. padding-left: 10px;
  15. }
  16. .inform h2 a {
  17. color: #FFFFFF;
  18. float: right;
  19. font-size: 14px;
  20. padding-right: 3px;
  21. }
  22. .inform ul {
  23. height: 170px;
  24. margin-top: 7px;
  25. overflow: hidden;
  26. }
  27. .inform ul li {
  28. line-height: 26px;
  29. padding-left: 12px;
  30. }

js实现消息滚动效果的更多相关文章

  1. JavaScript js无间断滚动效果 scrollLeft方法 使用模板

    JavaScript js无间断滚动效果 scrollLeft方法 使用模板 <!DOCTYPE HTML><html><head><meta charset ...

  2. 二、JavaScript语言--JS实践--信息滚动效果制作

    运用JavaScript技术,掌握无缝滚动和歇间性滚动的制作方法. 一.marquee标签实现信息滚动 1 behavior滚动的方式 alternate:表示在两端之间来回滚动 scroll:表示由 ...

  3. js实现页面消息滚动效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 用 Stellar.js 制作视差滚动效果

    参考 http://doc.bropaul.com/Stellar.js/docs/ https://github.com/markdalgleish/stellar.js#download http ...

  5. js 实现 间隙滚动效果

    代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3. ...

  6. js实现向上滚动效果

    源码: <style type="text/css"> #up_zzjs{border:1px solid #ccc;width:170px;height:182px; ...

  7. javascript跟随滚动效果插件代码(javascript Follow Plugin)

    这篇文章介绍了javascript跟随滚动效果插件代码(javascript Follow Plugin),有需要的朋友可以参考一下Js 跟随滚动效果插件支持定义多个跟随ID,采用css fixed属 ...

  8. js 实现文字滚动功能,可更改配置参数 带完整版解析代码。

    前言:         本人纯小白一个,有很多地方理解的没有各位大牛那么透彻,如有错误,请各位大牛指出斧正!小弟感激不尽.         本篇文章为您分析一下原生JS写文字滚动效果 需求分析: 需要 ...

  9. js鼠标滚轮滚动图片切换效果

    效果体验网址:http://keleyi.com/keleyi/phtml/image/12.htm HTML文件代码: <!DOCTYPE html PUBLIC "-//W3C// ...

随机推荐

  1. nmon监控分析

    一.下载软件安装 wget http://sourceforge.net/projects/nmon/files/nmon_linux_14i.tar.gz tar xf nmon_linux_14i ...

  2. 原生js实现删除class和添加class

    内容来自百度搜索 //判断样式是否存在 function hasClass(ele, cls) {     return ele.className.match(new RegExp("(\ ...

  3. java 的基本数据类型及转换

    数据类型精度: byte 8 位short 16 位int 32 位long 64 位float 32 位double 64 位char 16 位 boolean 占几位要看 jvm 的具体实现, 虽 ...

  4. Unity进阶----AssetBundle_03(2018/11/07)

    1. 为啥有AB包? 因为资源需要更新, 避免更新一次打包一次 动态修改. 2. AB包注意啥? 依赖关系 找依赖关系应该找到对应的平台!!! 3. 打包策略是分场景打包 若文件被文件夹包含打包出来的 ...

  5. 关于使用freemarker导出文档的使用

    7.FreeMarker导出word文件,模板:template.ftl/** * 为word加载数据插值 * * @throws IOException */ public void exportW ...

  6. 【XSS】利用 onload 事件监控流量劫持

    说到跨站资源监控,首先会联想到『Content Security Policy』.既然 CSP 好用,我们何必自己再搞一套呢.那就先来吐槽下 CSP 的缺陷. 目前的 CSP 日志不详细 用过 CSP ...

  7. 深入分析volatile的实现原理

    synchronized是一个重量级的锁,虽然JVM对它做了很多优化,而下面介绍的volatile则是轻量级的synchronized.如果一个变量使用volatile,则它比使用synchroniz ...

  8. [SQL]LeetCode596. 超过5名学生的课 | Classes More Than 5 Students

    SQL架构 Create table If Not Exists courses (student varchar(), )) Truncate table courses insert into c ...

  9. [Swift]LeetCode670. 最大交换 | Maximum Swap

    Given a non-negative integer, you could swap two digits at most once to get the maximum valued numbe ...

  10. GraphQL-前端开发的利剑与桥梁

    GraphQL-前端开发的利剑与桥梁 基本概念 GraphQL GraphQL 是一种用于 API 的查询语言,由Facebook开发和开源,是使用基于类型系统来执行查询的服务端运行时(类型系统由你的 ...