HTML 滚动轮播特效

 三秒自动滚动播放

<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
	<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>

    <div id="not3fahuo" style="overflow: hidden; height: 550.2px;"></div>

<script type="text/javascript" src="fangun.js"></script>
</body>
</html>

 

 


var not3chanpin=new Array("B","A");

function getfahuo(){
	var not3str="";
	if(not3chanpin.length !=0){
		not3str=not3str+not3chanpin[Math.floor((Math.random()*not3chanpin.length))]+" ";
	}
	return not3str;
}

var not3sheng=new Array(" 北京的"," 上海的"," 上海的"," 天津的"," 湖南的"," 湖北的"," 广东的"," 广西的"," 重庆的"," 四川的"," 山东的"," 河南的"," 河北的"," 山西的"," 贵州的"," 黑龙江的"," 福建的"," 浙江的"," 江苏的"," 江西的"," 海南的"," 陕西的");
var not3xing=new Array('赵**','钱**','孙**','李**','周**','吴**','郑**','王**','冯**','陈**','蒋**','沈**','韩**','杨**','朱**','秦**','许**','何**','吕**','张**','孔**','曹**','金**','魏**','陶**','姜**','谢**','苏**','范**','彭**','马**','方**','袁**','唐**','薛**','雷**','贺**','罗**');

function not3tel(){
   var not3telarr=new Array('13','15','18');
   var not3str="";
   not3str=not3telarr[parseInt(Math.random()*not3telarr.length)]+parseInt(Math.random()*10)+ '****'+ parseInt(Math.random()*10)+ parseInt(Math.random()*10)+parseInt(Math.random()*10)+parseInt(Math.random()*10);
   return "("+not3str+")";
}
   
function RndNum(n){
	var rnd="";
	for(var i=1;i<n;i++){
		rnd=Math.floor(Math.random()*10)+1;
	}
	return rnd;
}

not3fahuolist=("<ul>");
	for(i=0;i<22;i++){
		not3fahuolist=not3fahuolist+("<li><span>[最新购买]:<\/span>"+not3sheng[parseInt(Math.random()*not3sheng.length)]+' '+not3xing[parseInt(Math.random()*not3xing.length)]+" "+not3tel()+"在"+RndNum(30)+"分钟前订购了<br> "+getfahuo()+" <font color=\'#FF0000\'>√<\/font><br><br><\/li>");
	}
not3fahuolist=not3fahuolist+("<\/ul>");

function getHeight(){
	$("#not3fahuo").height();
} 
window.onload = function(){getHeight();} 
document.getElementById("not3fahuo").innerHTML=not3fahuolist;
$(function(){
	function scollDown(id,time){
          var liHeight=$("#"+id+" ul li").height();
          var time=time||2500;
          setInterval(function(){
          $("#"+id+" ul").prepend($("#"+id+" ul li:last").css("height","0px").animate({
          	height:liHeight+"px"
          },"slow"));
          },time);
	}
	scollDown("not3fahuo",3000);
});

if ($("#not3main").width()>749){
		document.write("<style>.not3order .not3orderl{float:left;display:inline;overflow:hidden;width:65%}.not3order .not3orderr{float:left;display:inline;overflow:hidden;width:35%}.not3order .not3forml .not3title img{margin-left:20px}</style>");}else{document.write("<style>.not3order .not3orderl{float:left;display:inline;overflow:hidden;width:100%}.not3order .not3orderr{float:left;display:inline;overflow:hidden;width:100%}</style>");
	}

 

可以使用 HTML、CSS 和 JavaScript 来实现自动滚动轮播图循环播放。以下是一个简单的示例: HTML 代码: ``` <div class="slider"> <div class="slide active"> <img src="slide1.jpg" alt="Slide 1"> </div> <div class="slide"> <img src="slide2.jpg" alt="Slide 2"> </div> <div class="slide"> <img src="slide3.jpg" alt="Slide 3"> </div> </div> ``` CSS 代码: ``` .slider { position: relative; width: 100%; height: 300px; overflow: hidden; } .slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1s ease; } .slide.active { opacity: 1; } .slide img { width: 100%; height: 100%; object-fit: cover; } ``` JavaScript 代码: ``` var slides = document.querySelectorAll('.slide'); var currentSlide = 0; var slideInterval = setInterval(nextSlide, 3000); function nextSlide() { slides[currentSlide].classList.remove('active'); currentSlide = (currentSlide + 1) % slides.length; slides[currentSlide].classList.add('active'); } ``` 以上代码中,首先使用 CSS 设置了轮播图容器 `.slider` 的样式,包括宽度、高度和溢出隐藏。然后设置每个轮播项 `.slide` 的样式,使用了绝对定位和不透明度来实现轮播效果,还设置了图片的填充方式。最后,使用 JavaScript 实现了自动滚动和循环播放的逻辑,使用了计时器 `setInterval` 来定时调用 `nextSlide` 函数,该函数会根据当前轮播项的索引值,切换到下一个轮播项,并更新相应的样式。 需要注意的是,以上示例中只考虑了基本的轮播功能,如果需要添加其他特效或功能,可以根据具体需求进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值