案例---左右焦点轮播图(tb)

<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<title></title>
<style>
body,
ul,
ol,
li,
img {
margin: 0;
padding: 0;
list-style: none;
} #box {
width: 520px;
height: 280px;
padding: 5px;
position: relative;
border: 1px solid #ccc;
margin: 100px auto 0;
} .ad {
width: 520px;
height: 280px;
/*overflow: hidden;*/
position: relative;
} #box img {
width: 520px;
} .ad ol {
position: absolute;
right: 10px;
bottom: 10px;
} .ad ol li {
width: 20px;
height: 20px;
line-height: 20px;
border: 1px solid #ccc;
text-align: center;
background: #fff;
float: left;
margin-right: 10px;
cursor: pointer;
_display: inline;
} .ad ol li.current {
background: yellow;
} .ad ul li {
float: left;
} .ad ul {
position: absolute;
top: 0;
width: 2940px;
} .ad ul li.current {
display: block;
} #focusD {
display: none;
} #focusD span {
width: 40px;
height: 40px;
position: absolute;
left: 5px;
top: 50%;
margin-top: -20px;
background: #000;
cursor: pointer;
line-height: 40px;
text-align: center;
font-weight: bold;
font-family: '黑体';
font-size: 30px;
color: #fff;
opacity: 0.3;
border: 1px solid #fff;
} #focusD #right {
right: 5px;
left: auto;
}
</style>
</head> <body>
<div id="box" class="all">
<div class="ad">
<ul id="imgs">
<li><img src="data:images/01.jpg" /></li>
<li><img src="data:images/02.jpg" /></li>
<li><img src="data:images/03.jpg" /></li>
<li><img src="data:images/04.jpg" /></li>
<li><img src="data:images/05.jpg" /></li>
</ul>
</div>
<!--相框-->
<div id="focusD"><span id="left">&lt;</span><span id="right">&gt;</span>
</div>
</div>
<script src="common.js"></script>
<script> //获取最外面的div
var box = my$("box");
//获取相框
var ad = box.children[0];
//获取相框的宽度
var imgWidth = ad.offsetWidth;
//获取ul
var ulObj = ad.children[0];
//获取装span左右焦点的div
var focusD = my$("focusD"); //显示和隐藏左右焦点的div----为box注册事件
box.onmouseover = function () {
focusD.style.display = "block";
};
box.onmouseout = function () {
focusD.style.display = "none";
}; //点击右边的按钮
var index = 0;
my$("right").onclick = function () {
if (index < ulObj.children.length - 1) {
index++;
animate(ulObj, -index * imgWidth);
}
};
//点击左边的按钮
my$("left").onclick = function () {
if (index > 0) {
index--;
animate(ulObj, -index * imgWidth);
}
}; </script> </body> </html>

最新文章

  1. java中内存分配策略及堆和栈的比较
  2. C#创建委托实例
  3. MySQL数据库的一些基本操作及注释
  4. A strange lift_BFS
  5. ArcGIS Wpf MarkerSymbol 图形符号无法序列化为 JSON
  6. iOS 如何使用自定义字体
  7. MVC中@Html.DisPlayFor(model=&gt;model.newsName)和 @Model.newsName的区别
  8. 创建数据库和表的SQL语句【转】
  9. CentOS下用pyenv 和 virtualenv 搭建单机多版本python 虚拟开发环境
  10. Emmet语法
  11. JDBC_mysql---防sql注入,存储图片
  12. win8 VS2010 配制OpenGL
  13. NDK Android* 应用移植方法
  14. JS中关于clientWidth offsetWidth scrollWidth 的区别及意义
  15. 《ServerSuperIO Designer IDE使用教程》-3.Modbus协议,读取多个寄存器,实现多种数据类型解析。发布:v4.2.2版本
  16. 美团小程序框架mpvue入门
  17. 7I - 数塔
  18. nuxt二级路由
  19. Elasticsearch 自定义多个分析器
  20. Codeforces 191A - Dynasty Puzzles - [DP]

热门文章

  1. JVM学习笔记(1)--运行时数据区域
  2. Python3学习-基础
  3. django-formset实现数据表的批量操作
  4. Python的特有的参数传递(*和**)
  5. 2019-2020-1 20199304《Linux内核原理与分析》第一周作业
  6. 深入比特币原理(四)——锁定脚本(locking script)与解锁脚本(unlocking script)
  7. Python ——selenium报错 &#39;chromedriver.exe&#39; executable needs to be in PATH
  8. 遍历json数据的几种方式。
  9. redis位图巧用,节约内存
  10. Spring代理模式(CGLIB动态代理模式)