明霞山资源网 Design By www.htccd.com
最简单轮播形式,js中通过pic的display属性控制变换,也可通过调整Pic的margin-Left
效果如图:
实现代码:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
list-style: none;
text-decoration: none;
}
.wrap{
width: 490px;
height: 170px;
margin: 100px auto;
border: 1px solid #000000;
position: relative;
overflow: hidden;
}
#pic{
width: 2450px;
height: 170px;
}
#pic li{
float: left;
}
#list{
position: absolute;
bottom: 10px;
left:150px ;
}
#list li{
float: left;
width: 15px;
height: 15px;
background: #fff;
margin: 0 10px;
border-radius: 50%;
cursor: pointer;
}
#list .on{
background: #e27a00;
}
.Prev{
top: 30px;
left: 0;
}
.Next{
top: 30px;
right: 0;
}
.Prev,.Next{
position: absolute;
font-size: 80px;
font-weight: bold;
color:#fff ;
-webkit-transition: all 0.35s ease-in-out
}
.Next:hover,
.Prev:hover{
background: #ccc;
background: rgba(204, 204, 204, 0.4);
}
.show{
display: block;
}
.hidden{
display: none;
}
</style>
<script type="text/javascript">
window.onload=function(){
var pic=document.getElementById('pic').getElementsByTagName('li');
var list=document.getElementById('list').getElementsByTagName('li');
var prev=document.getElementById('Prev');
var next=document.getElementById('Next');
var index=0;
var timer=null;
auto();
for(var i=0;i<list.length;i++){
list[i].index=i;
list[i].onmouseover=function(){
clearInterval(timer);
Change(this.index);
}
list[i].onmouseout=function(){
auto();
}
pic[i].onmouseover=function(){
clearInterval(timer);
}
pic[i].onmouseout=function(){
auto();
}
}
prev.onclick=function(){
clearInterval(timer);
index--;
if(index<=0){
index=list.length-1;
}
Change(index);
}
next.onclick=function(){
clearInterval(timer);
index++;
if(index>=list.length){
index=0;
}
Change(index);
}
prev.onmousemove=function(){
clearInterval(timer);
}
prev.onmouseout=function(){
auto();
}
next.onmouseover=function(){
clearInterval(timer);
}
next.onmouseout=function(){
auto();
}
function Change(curIndex){
for(var i=0;i<list.length;i++){
list[i].className="";
pic[i].className="hidden";
}
list[curIndex].className="on";
pic[curIndex].className="show";
index=curIndex;
}
function auto(){
timer=setInterval(function(){
index++;
if(index>=list.length){
index=0
}
Change(index);
},2000);
}
}
</script>
</head>
<body>
<div class="wrap" id="wrap">
<ul id="pic">
<li class="show"><a href="#"><img src="/UploadFiles/2021-04-02/54111cd9000174cd04900170.jpg">
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
明霞山资源网 Design By www.htccd.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
明霞山资源网 Design By www.htccd.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
