国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

居然可以用jQuery實現(xiàn)360度汽車產(chǎn)品3D旋轉(zhuǎn)展示酷炫特效 使用你的小鼠標(biāo)來試試吧

2022-07-08 20:21 作者:極客小俊GeekerJun  | 我要投稿

?? 作者:極客小俊
* 把邏輯思維轉(zhuǎn)變?yōu)榇a的技術(shù)博主



在這里插入圖片描述

今天我們來看一個用jquery實現(xiàn)360度汽車產(chǎn)品3D旋轉(zhuǎn)展示的效果,其實邏輯很簡單, 就是讓一堆圖片轉(zhuǎn)來轉(zhuǎn)去就行了!????

準(zhǔn)備工作

  1. 準(zhǔn)備一個jquery庫,這里我用的是jquery1.11.3.js 沒有的朋友自行官網(wǎng)下載!

  2. 準(zhǔn)備一堆汽車圖片和按鈕圖片,并且把汽車圖的名稱改成有序的數(shù)值, 如下 如圖

在這里插入圖片描述
  1. 好了準(zhǔn)備工作做好了, 接下來不廢話直接上代碼

HTML結(jié)構(gòu) ???

<div id="box">
? ?<img src="img/1.png" id="img" title="" alt="" width="" height=""/>
? ?<div class="btn">
? ? ? ?<a href="javascript:;" class="prev" id="prev"></a>
? ? ? ?<a href="javascript:;" class="next" id="next"></a>
? ?</div>
</div>


CSS樣式代碼 ??

*{
? ?margin: 0px;
? ?padding: 0px;
}

a{
? ?text-decoration: none;
}

body{
? ?font-family: '微軟雅黑';
? ?background: #f9f7f6;
}

ul,ol{
? ?list-style: none;
}


#box{
? ?width: 1000px;
? ?height: 447px;
? ?margin: 50px auto;
? ?position: relative;
}

#box>.btn{
? ?width: 88px;
? ?height: 44px;
? ?position: absolute;
? ?bottom: 10px;
? ?left: calc(50% - 44px);
}

#box>.btn>a:nth-child(1), #box>.btn>a:nth-child(2){
? ?height: 44px;
? ?width: 44px;
? ?float: left;
}

#box>.btn>a:nth-child(1){
? ?background: url("img/arrows.png") no-repeat;
}

#box>.btn>a:nth-child(2){
? ?background: url("img/arrows.png") no-repeat -44px 0px;
}

jQuery 代碼邏輯??

? $(function(){
? ? ? ?var i=0; //圖片的數(shù)字名稱
? ? ? ?var timer=null;
? ? ? ?var stop=1;

? ? ? ?function _fnLeft(){
? ? ? ? ? ?i++;
? ? ? ? ? ?if(i>=51){
? ? ? ? ? ? ? ?i=1;
? ? ? ? ? ?}
? ? ? ? ? ?$("#img").attr("src","img/"+i+".png");
? ? ? ?}

? ? ? ?function _fnRight(){
? ? ? ? ? ?i--;
? ? ? ? ? ?if(i<=1){
? ? ? ? ? ? ? ?i=51;
? ? ? ? ? ?}
? ? ? ? ? ?$("#img").attr("src","img/"+i+".png");
? ? ? ?}

? ? ? ?//當(dāng)鼠標(biāo)移動到next上的時候
? ? ? ?$("#next").hover(
? ? ? ? ? ?function(){
? ? ? ? ? ? ? ?console.log(stop);
? ? ? ? ? ? ? ?timer=setInterval(_fnLeft,50);
? ? ? ? ? ?},
? ? ? ? ? ?function(){
? ? ? ? ? ? ? ?stop=1;
? ? ? ? ? ? ? ?clearInterval(timer);
? ? ? ? ? ?}
? ? ? ?);

? ? ? ?//當(dāng)鼠標(biāo)移動到prev上的時候
? ? ? ?$("#prev").hover(
? ? ? ? ? ?function(){
? ? ? ? ? ? ? ?timer=setInterval(_fnRight,50);
? ? ? ? ? ?},
? ? ? ? ? ?function(){
? ? ? ? ? ? ? ?stop=1;
? ? ? ? ? ? ? ?clearInterval(timer);
? ? ? ? ? ?}
? ? ? ?);

? ? ? ?$("#next").click(function(){
? ? ? ? ? ?stop*=-1;
? ? ? ? ? ?if(stop==-1){
? ? ? ? ? ? ? ?clearInterval(timer);
? ? ? ? ? ?}else if(stop==1){
? ? ? ? ? ? ? ?timer=setInterval(_fnLeft,50);
? ? ? ? ? ?}
? ? ? ?})

? ? ? ?$("#prev").click(function(){
? ? ? ? ? ?stop*=-1;
? ? ? ? ? ?if(stop==-1){
? ? ? ? ? ? ? ?clearInterval(timer);
? ? ? ? ? ?}else if(stop==1){
? ? ? ? ? ? ? ?timer=setInterval(_fnRight,50);
? ? ? ? ? ?}
? ? ? ?})
? ?})

最終效果??

如圖

在這里插入圖片描述

怎么樣 是不是很簡單呢 ,趕緊試試吧! ?????? 挺好玩的!





大家的支持就是我堅持的動力!

如果文章對你有幫助的話就請

???點贊 ??評論 ??收藏

一鍵三連哦!

如果以上內(nèi)容有任何錯誤或者不準(zhǔn)確的地方,????歡迎在下面 ?? 留個言指出!

或者你有更好的想法,歡迎一起交流學(xué)習(xí)??????????


居然可以用jQuery實現(xiàn)360度汽車產(chǎn)品3D旋轉(zhuǎn)展示酷炫特效 使用你的小鼠標(biāo)來試試吧的評論 (共 條)

分享到微博請遵守國家法律
梅河口市| 西青区| 绩溪县| 江口县| 德格县| 确山县| 濮阳县| 新干县| 巫溪县| 思茅市| 日土县| 海口市| 舞钢市| 萝北县| 北流市| 铜陵市| 洛宁县| 大港区| 舒城县| 青岛市| 黄梅县| 清苑县| 任丘市| 大宁县| 蛟河市| 凌海市| 敖汉旗| 客服| 财经| 彭阳县| 那曲县| 绥化市| 东乡| 安泽县| 甘肃省| 外汇| 宿迁市| 阿克陶县| 翁牛特旗| 盐源县| 广安市|