首頁banner的酷炫效果多來自全螢幕大圖的幻燈片動畫,以下提供一種完美相容的jquery動畫特效:全新jquery多點滑動幻燈片-全螢幕動畫animateSlide(程式碼完全原創)。
直接上程式碼,把html、css和jquery程式碼copy到頁面上即可呈現完美畫面。
html程式碼如下:
<div class="animateSlide"> <div class="animateSlideImgWrap"> <div class="animateSlideImgBox present"> <p class="text1">亲,这是第一行标题</p> <p class="text2">AAAAAAAAAAAAAAAAAAAAA</p> <!--<img class="img lazy" src="/static/imghwm/default1.png" data-src="img/1.png" alt="" />--> <div class="img" style="width: 500px; height: 390px; background: #ffaeae; opacity: 0.6;"></div><!-- 实际项目中用上面注释的半透明png图片,目前临时用div代替图片 --> </div> <div class="animateSlideImgBox"> <p class="text1">亲,这是一行宣传语</p> <p class="text2">BBBBBBBBBBBBBBBBBBBBB</p> <!--<img class="img lazy" src="/static/imghwm/default1.png" data-src="img/2.png" alt="" />--> <div class="img" style="width: 500px; height: 390px; background: #aeffb2; opacity: 0.6;"></div><!-- 实际项目中用上面注释的半透明png图片,目前临时用div代替图片 --> </div> <div class="animateSlideImgBox"> <p class="text1">亲,这是一个奇迹啊</p> <p class="text2">CCCCCCCCCCCCCCCCCCCCC</p> <!--<img class="img lazy" src="/static/imghwm/default1.png" data-src="img/3.png" alt="" />--> <div class="img" style="width: 500px; height: 390px; background: #aebdff; opacity: 0.6;"></div><!-- 实际项目中用上面注释的半透明png图片,目前临时用div代替图片 --> </div> </div> <div class="animateSlideBtnL"><</div> <div class="animateSlideBtnR"><</div> </div>
css程式碼如下:
.animateSlide {width: 100%; height: 390px; position: relative; background: #f5f5f5;} .animateSlideImgWrap {width: 100%; height: 390px; position: absolute; z-index: 1; overflow: hidden;} .animateSlideImgWrap .present {display: block;} .animateSlideImgBox {width: 100%; height: 390px; position: absolute; z-index: 1; display: none;} .animateSlideImgBox .text1 {font-family: Microsoft YaHei; font-size: 36px; line-height: 1.2em; color: #384cd0; position: absolute; top: 120px; z-index: 3; white-space: nowrap;} .animateSlideImgBox .text2 {font-family: Microsoft YaHei; font-size: 26px; line-height: 1.2em; color: orange; position: absolute; top: 200px; z-index: 3; white-space: nowrap;} .animateSlideImgBox .img {position: absolute; left: 470px; top: 0; z-index: 2;} .animateSlideBtnL, .animateSlideBtnR { width: 30px; height: 60px; line-height: 60px; font-size: 20px; font-weight: 700; text-align: center; background: #ddd; position: absolute; left: 30px; top: 150px; z-index: 6; cursor: pointer; display: none; } .animateSlideBtnR {left: auto; right: 20px;}
jquery程式碼如下:
(function($) { $.fn.animateSlide = function(options) { var defaults = { btnL: ".animateSlideBtnL", btnR: ".animateSlideBtnR", imgBox: ".animateSlideImgBox", animateTime: 500, delayTime: 5000, density: 1 }; var opts = $.extend(defaults, options); var widthWin = $(window).width(); $(window).resize(function() { widthWin = $(window).width(); }); // this.on("mouseenter", function() { $(this).find(".animateSlideBtnL, .animateSlideBtnR").stop().fadeIn(400); }).on("mouseleave", function() { $(this).find(".animateSlideBtnL, .animateSlideBtnR").stop().fadeOut(400); }); return this.each(function() { var _this = $(this); var _btnL = _this.find(opts.btnL); var _btnR = _this.find(opts.btnR); var _imgBox = _this.find(opts.imgBox); var _imgBoxCur = _imgBox.filter(".present"); var _curText1 = _imgBoxCur.find(".text1"), _curText2 = _imgBoxCur.find(".text2"), _curImg = _imgBoxCur.find(".img"); var _imgBoxNext = null, _nextText1 = null, _nextText2 = null, _nextImg = null; var index = _imgBox.index(_imgBoxCur) || 0; var size = _imgBox.size(); var start = null; index++; if(index >= size) { index = 0; } _imgBoxNext = _imgBox.eq(index); _nextText1 = _imgBoxNext.find(".text1"); _nextText2 = _imgBoxNext.find(".text2"); _nextImg = _imgBoxNext.find(".img"); _imgBox.find(".text1, .text2, .img").css("left", widthWin); _imgBoxCur.find(".text1, .text2").css("left", (widthWin - 980) / 2 + "px"); _imgBoxCur.find(".img").css("left", (widthWin - 980) / 2 + 470 + "px"); _btnR.on("click", function() { animateSlideFn(); }); _btnL.on("click", function() { animateSlideFn(); }); start = setTimeout(function() { animateSlideFn(); start = setTimeout(arguments.callee, opts.delayTime); }, opts.delayTime); function animateSlideFn() { if(!(_imgBoxCur.find(".text1, .text2, .img").is(":animated") || _imgBoxNext.find(".text1, .text2, .img").is(":animated"))) { //当前帧动画 _curText1.animate({ left: parseInt(_curText1.css("left")) + 100 }, opts.animateTime * 0.6, function() { _curText1.animate({ left: "-510px" }, opts.animateTime); }); setTimeout(function() { _curText2.animate({ left: parseInt(_curText2.css("left")) + 100 }, opts.animateTime * 0.6, function() { _curText2.animate({ left: "-510px" }, opts.animateTime); }); }, 200); setTimeout(function() { _curImg.animate({ left: parseInt(_curImg.css("left")) + 200 }, opts.animateTime * 0.6, function() { _curImg.animate({ left: "-510px" }, opts.animateTime, function() { _imgBox.find(".text1, .text2, .img").css("left", widthWin); _imgBoxCur.removeClass("present"); }); }); }, 400); //下一帧动画 setTimeout(function() { _imgBoxNext.addClass("present"); _nextText1.animate({ left: (widthWin - 980) / 2 - 100 }, opts.animateTime, function() { _nextText1.animate({ left: (widthWin - 980) / 2 }, opts.animateTime * 0.6); }); setTimeout(function() { _nextText2.animate({ left: (widthWin - 980) / 2 - 100 }, opts.animateTime, function() { _nextText2.animate({ left: (widthWin - 980) / 2 }, opts.animateTime * 0.6); }); }, 200); setTimeout(function() { _nextImg.animate({ left: (widthWin - 980) / 2 + 370 }, opts.animateTime, function() { _nextImg.animate({ left: (widthWin - 980) / 2 + 470 }, opts.animateTime * 0.6, function() { index++; if(index >= size) { index = 0; } _imgBoxCur = _imgBox.filter(".present"); _imgBoxNext = _imgBox.eq(index); _curText1 = _imgBoxCur.find(".text1"); _curText2 = _imgBoxCur.find(".text2"); _curImg = _imgBoxCur.find(".img"); _nextText1 = _imgBoxNext.find(".text1"); _nextText2 = _imgBoxNext.find(".text2"); _nextImg = _imgBoxNext.find(".img"); }); }); }, 400); }, opts.density * 1200); } } }); }; })(jQuery); $(function() { $(".animateSlide").animateSlide({ btnL: ".animateSlideBtnL", btnR: ".animateSlideBtnR", imgBox: ".animateSlideImgBox", animateTime: 500, delayTime: 6000, density: 0.9 }); });

javaandjavascriptaredistinctlanguages:javaisusedforenterpriseandmobileapps,while javascriptifforInteractiveWebpages.1)JavaisComcompoppored,statieldinglationallyTypted,statilly tater astrunsonjvm.2)

JavaScript核心數據類型在瀏覽器和Node.js中一致,但處理方式和額外類型有所不同。 1)全局對像在瀏覽器中為window,在Node.js中為global。 2)Node.js獨有Buffer對象,用於處理二進制數據。 3)性能和時間處理在兩者間也有差異,需根據環境調整代碼。

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

Python和JavaScript的主要區別在於類型系統和應用場景。 1.Python使用動態類型,適合科學計算和數據分析。 2.JavaScript採用弱類型,廣泛用於前端和全棧開發。兩者在異步編程和性能優化上各有優勢,選擇時應根據項目需求決定。

選擇Python還是JavaScript取決於項目類型:1)數據科學和自動化任務選擇Python;2)前端和全棧開發選擇JavaScript。 Python因其在數據處理和自動化方面的強大庫而備受青睞,而JavaScript則因其在網頁交互和全棧開發中的優勢而不可或缺。

Python和JavaScript各有優勢,選擇取決於項目需求和個人偏好。 1.Python易學,語法簡潔,適用於數據科學和後端開發,但執行速度較慢。 2.JavaScript在前端開發中無處不在,異步編程能力強,Node.js使其適用於全棧開發,但語法可能複雜且易出錯。

javascriptisnotbuiltoncorc; sanInterpretedlanguagethatrunsonenginesoftenwritteninc.1)JavascriptwasdesignedAsignedAsalightWeight,drackendedlanguageforwebbrowsers.2)Enginesevolvedfromsimpleterterpretpretpretpretpreterterpretpretpretpretpretpretpretpretpretcompilerers,典型地,替代品。

JavaScript可用於前端和後端開發。前端通過DOM操作增強用戶體驗,後端通過Node.js處理服務器任務。 1.前端示例:改變網頁文本內容。 2.後端示例:創建Node.js服務器。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

禪工作室 13.0.1
強大的PHP整合開發環境

SublimeText3漢化版
中文版,非常好用