TD中{text-overflow:ellipsis;} 用法

Styles:

table{ table-layout:fixed; } 
table td{ text-overflow:ellipsis;overflow:hidden;white-space: nowrap; }

转载于:https://www.cnblogs.com/njl041x/p/4112662.html

<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <style> #mq { width: 270px; padding-left: 5px; } .ctl { table-layout: fixed } .ctl td { overflow: hidden; white-space: nowrap; height: 24px; text-overflow: ellipsis } li { padding: 0px; font-size: 9pt; margin: 0px; line-height: 1.8em; border: 0px none #CCF; } </style> </head> <body> <table height="24" cellSpacing="0" cellPadding="0" border="0"> <tbody> <tr> <td width="275" background="images/01.gif"> <div id="mq" style="overflow: hidden; height: 24px" onmouseover=iScrollAmount=0 onmouseout=iScrollAmount=1> <table class="ctl" cellSpacing="0" cellPadding="0" width="275" border="0"> <tbody> <tr><td><li>关于做好我省普通高等学校招生工作的通知</li></td></tr> <tr><td><li>关于做好我省普通高等学校对口招生工作的通知</li></td></tr> <tr><td><li>关于做好我省技能竞赛工作的通知</li></td></tr> <tr><td><li>关于做好我省职称评定工作的通知</li></td></tr> </tbody> </table> </div> </td> </tr> </tbody> </table> <script> var oMarquee = Document.getElementById("mq"); var iLineHeight = 24; var iLineCount = 1; var iScrollAmount = 1; function run(){ oMarquee.scrollTop += iScrollAmount; if(oMarquee.scrollTop == iLineHeight*iLineCount) oMarquee.scrollTop = 0 if(oMarquee.scrollTop % iLineHeight*iLineCount == 0){ window.setTimeout("run()",2000); }else{ window.setTimeout("run()",50); } oMarquee.innerHTML += oMarquee.innerHTML; window.setTimeout("run()",2000); </script> </body> </html>
最新发布
05-22
### 实现简单的滚动效果 通过 JavaScript 和 HTML 的结合可以轻松实现页面的滚动效果。以下是具体的方法: #### 使用 `window.scrollBy` 方法 可以通过调用 `window.scrollBy(x, y)` 来实现页面按指定像素量进行滚动的效果[^1]。 ```javascript // autoScroll.js 文件中的核心逻辑 var start = document.getElementById('start'); // 开始按钮 var stop = document.getElementById('stop'); // 停止按钮 var timer = null; // 定义定时器变量 var key = true; // 控制开关状态 start.addEventListener('click', function () { if (key === true) { timer = setInterval(function () { window.scrollBy(0, 10); // 页面每次向下滚动 10 像素 }, 100); key = false; } }); stop.addEventListener('click', function () { clearInterval(timer); // 清除定时器,停止滚动 key = true; }); ``` #### 结合 HTML 创建交互界面 为了使用户能够控制滚动行为,可以在 HTML 中创建两个按钮用于启动和停止滚动操作。 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>简单滚动效果</title> <style> body { height: 200vh; /* 设置足够的高度以便测试滚动 */ } .button-container { margin-top: 50px; } </style> </head> <body> <div class="button-container"> <button id="start">开始滚动</button> <button id="stop">停止滚动</button> </div> <script src="autoScroll.js"></script> </body> </html> ``` 以上代码实现了当用户点击“开始滚动”按钮时,页面将以每秒多次的速度向下滑动;而点击“停止滚动”按钮则会立即终止该动作[^1]。 #### 返回顶部功能扩展 如果希望进一步增强用户体验,还可以加入一个返回顶部的功能按钮,并使其随页面滚动保持固定位置显示[^2]。 ```css /* CSS 样式部分 */ .rTop { width: 100px; height: 25px; text-align: center; font-size: small; line-height: 25px; border: 1px solid #999; background-color: white; color: black; cursor: pointer; position: fixed; right: 10px; bottom: 10px; } ``` ```javascript // 添加到现有的 JS 脚本中 document.querySelector('.rTop').addEventListener('click', function() { window.scrollTo({ top: 0, behavior: 'smooth' }); // 平滑回到顶部 }); ``` ```html <!-- 在 HTML 文档底部添加 --> <button class="rTop">返回顶部</button> ``` 这样不仅提供了基本的自动滚动能力,还增加了便捷的操作选项来改善整体浏览体验[^2]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值