搜索
博主信息
博文 4
粉丝 0
评论 0
访问量 3641
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
图片左右切换
syqaily的博客
原创
838人浏览过

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

<style>

body,p{margin: 0; padding: 0;}

img{border: none; vertical-align: top;}

#box{width: 400px; height: 400px; border: 5px solid #ccc; margin: 100px auto 0; position: relative; font-size: 14px; font-family: "微软雅黑";}

#p1,#span1,a{position: absolute; color: #fff;}

#p1,#span1{left: 0; height: 30px; line-height: 30px; background: #000; opacity: 0.5; filter:alpha(opacity=50); width: 400px; text-align: center;}

#p1{bottom: 0;}

#span1{top: 0;}

a{font-size: 30px; color: #fff; top:185px; text-decoration: none;}

a:hover{opacity: 0.5;filter:alpha(opacity=50);}

#prev{left: 0;}

#next{right: 0;}

</style>

</head>

<body>

<div id="box">

<img src="" id="img1"  width="400" height="400"/>

<p id="p1">11</p>

<span id="span1">22</span>

<a href="javascript:;" id="prev">&lt;</a>

<a href="javascript:;" id="next">&gt;</a>

</div>

<script type="text/javascript">

            var oImg=document.getElementById('img1');

            var oP=document.getElementById('p1');

            var oSpan=document.getElementById('span1');

            var oPrev=document.getElementById('prev');

            oNext=document.getElementById('next');

            var arrImg=['img/1.jpg','img/2.jpg','img/3.jpg','img/4.jpg'];

            var arrText=['第一句话','第二句话','第三句话','第四句话'];

            var num=0;

            auto();

            function auto(){

           oImg.src=arrImg[num];

           oP.innerHTML=arrText[num];

           oSpan.innerHTML=num+1+'/'+arrImg.length;

            }

            oNext.onclick=function(){

            if(num<3){

             num++;

            }else

            {

            num=0;

            }

   auto();

            }

            oPrev.onclick=function(){

            if(num>0){

            num--;

            }else

            {

            num=arrImg.length-1;

            }          

            auto();

            }

</script>

</body>

</html>


本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学