JS+CSS 实现 悬浮滚动广告
来源:互联网 发布:股权众筹系统源码 编辑:程序博客网 时间:2024/06/05 03:17
- 效果图
- 思路
- 代码
效果图:
思路:
布局一个绝对布局的div 写一个move方法改变div的left 和top值
需要注意 到达body边界时候 改变方向
然后设置定时器调用move方法 不断改变 left和top值
代码:
<html lang="en"><head> <meta charset="UTF-8"> <title>移动的小广告</title></head><body> <div id="xgg" style="position: absolute;left: 0px;top: 0;"> <img src="images/123.jpg" alt=""> </div> <script> var xleft=0; var ytop=0; var movex=1; var movey=1; function move(){ xleft+=movex; ytop+=movey; var xgg=document.getElementById("xgg"); xgg.style.top=ytop; xgg.style.left=xleft; if(xleft+xgg.offsetWidth>=document.body.clientWidth|| xleft<=0){ movex=-movex; }//注意 document.body.clientHeight 兼容问题 if(ytop+xgg.offsetHeight>=document.body.clientHeight||ytop<=0){ movey=-movey; } } setInterval(move,10); </script></body></html>
0 0
- JS+CSS 实现 悬浮滚动广告
- 原生js实现和jQuery实现 屏幕自由滚动广告 悬浮停止
- CSS实现广告右侧悬浮效果
- js悬浮广告效果
- Js悬浮广告效果
- js 悬浮广告
- JS+CSS 实现 悬停广告
- js + css实现左侧悬浮导航栏
- JS右下角悬浮广告代码
- js滚动广告效果
- js滚动广告效果
- js滚动广告效果
- js 实现页面两边广告, 可关闭对联广告 随滚动条滚动 符合w3c标准
- js 实现页面两边广告, 可关闭对联广告 随滚动条滚动 符合w3c标准
- Jquery实现广告滚动
- Android_ViewPager实现滚动广告
- css + js实现简单无缝滚动字幕
- css+js实现进度滚动条
- CodeForces 427A
- CodeForces 274A k-Multiple Free Set【思维】
- UVA - 297 Quadtrees
- 面向对象
- UVA301Transportation
- JS+CSS 实现 悬浮滚动广告
- Git知识整理
- poj1213Fantasy of a Summation(找规律,优化代码)
- FFT模板
- 原码补码反码之间的关系
- python 设置线程名
- mongodb c++ API
- 5.4 编写一个程序,求以下矩形两条对角线上的元素之和:
- linux后台运行任务——screen