一个简单的banner
2016-07-04 23:40
253 查看
源码:
<html>
<head>
<title>一个简单banner</title>
<style>
*{margin:0;padding:0;}
.banner{height:200px;width:200px;height:120px;background-size:cover;margin:100px 0 0 200px;}
li{float:left;}
.right{margin-top:-180px;margin-left:352px;height:120px;width:50px;cursor:pointer;}
.left{margin-top:-180px;margin-left:0px;height:120px;width:50px;cursor:pointer;}
img{width:400px;height:300px;}
</style>
</head>
<body>
<div class="banner">
<img src="images/01.jpg" id="pc"/>
<img type="button" src="images/right.jpg" class="right" onclick="r_change()" />
<img src="images/left.jpg" class="left" onclick="l_change()" />
</div>
<script type="text/javascript">
var index = 1;
window.onload=function(){
var p = document.getElementById("pc");
p.src="images/01.jpg";
}
//左切换
function r_change(){
var p = document.getElementById("pc");
index++;
var x = index % 6;
if(x == 0){
index = 1;
}
else{
index = x;
}
p.src="images/0"+index+".jpg";
}
//右切换
function l_change(){
var p = document.getElementById("pc");
index--;
var x = index % 6;
if(x == 0){
index = 5;
}
else{
index = x;
}
p.src="images/0"+index+".jpg";
}
</script>
</body>
</html>
<html>
<head>
<title>一个简单banner</title>
<style>
*{margin:0;padding:0;}
.banner{height:200px;width:200px;height:120px;background-size:cover;margin:100px 0 0 200px;}
li{float:left;}
.right{margin-top:-180px;margin-left:352px;height:120px;width:50px;cursor:pointer;}
.left{margin-top:-180px;margin-left:0px;height:120px;width:50px;cursor:pointer;}
img{width:400px;height:300px;}
</style>
</head>
<body>
<div class="banner">
<img src="images/01.jpg" id="pc"/>
<img type="button" src="images/right.jpg" class="right" onclick="r_change()" />
<img src="images/left.jpg" class="left" onclick="l_change()" />
</div>
<script type="text/javascript">
var index = 1;
window.onload=function(){
var p = document.getElementById("pc");
p.src="images/01.jpg";
}
//左切换
function r_change(){
var p = document.getElementById("pc");
index++;
var x = index % 6;
if(x == 0){
index = 1;
}
else{
index = x;
}
p.src="images/0"+index+".jpg";
}
//右切换
function l_change(){
var p = document.getElementById("pc");
index--;
var x = index % 6;
if(x == 0){
index = 5;
}
else{
index = x;
}
p.src="images/0"+index+".jpg";
}
</script>
</body>
</html>
相关文章推荐
- 谈谈网页设计中的字体应用Font Set
- 网页设计中的 serif 和 sans-serif字体应用
- jquery实现简单的banner轮播效果【实例】
- JS实现带关闭功能的阿里妈妈网站顶部滑出banner工具条代码
- Android实现Banner界面广告图片循环轮播(包括实现手动滑动循环)
- jQuery+css3动画属性制作猎豹浏览器宽屏banner焦点图
- 简单的jQuery banner图片轮播实例代码
- 为你的响应式设计提速
- CSS3 Media Queries(响应式布局可以让你定制不同的分辨率和设备)
- css3的@media属性实现页面响应式布局示例代码
- css3与html5实现响应式导航菜单(导航栏)效果分享
- 国外优秀网站标志
- 纯CSS实现的响应式图像显示(无javaScript)
- 网页布局之响应式设计简明指南
- 响应式网页设计的快速教程(适合个人站点)
- 一款纯css3实现的响应式导航
- 支持IE8的纯css3开发的响应式设计动画菜单教程
- 实列教程 一款基于jquery和css3的响应式二级导航菜单
- 使用jquery实现HTML5响应式导航菜单教程