明霞山资源网 Design By www.htccd.com
首页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" alt="" src="/UploadFiles/2021-04-02/1.png">
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
});
});
明霞山资源网 Design By www.htccd.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
明霞山资源网 Design By www.htccd.com
暂无评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。