怎么实现jquery版结婚电子请帖
短信预约 -IT技能 免费直播动态提醒
怎么实现jquery版结婚电子请帖,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
老姐看了jquery版小型婚礼(可动态添加祝福语),觉得还不错,就让我给他们做一个电子请帖。已经做了大半年了,懒着一直没发……趁现在想起来了,就赶紧放上来让大家看看。
一、图片展示
1.开场动画
新人开着小轿车缓缓向我们驶来,从这头到那头,其中的滋味醉在心头。
2.首页
首页包括相册、邀请函、祝福墙和婚礼地址。
1).相册
相册集,由12张小图片组成一个心形,图片自循环逐张变大再变小。
2).邀请函
两情相悦只要证到手,又启在朝朝暮暮。
3).祝福墙
祝福墙动画:
留言板:
4).婚礼地址
二、代码展示
1.html代码
<!DOCTYPE HTML > <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <title></title> <link rel="stylesheet" type="text/css" href="css/reset.css"> <link rel="stylesheet" type="text/css" href="css/index.css"> </head> <body> <!--[if ie 6]> <style type="text/css"> .mask {position: absolute; height: 800px;} .pop-box {_position: absolute;} </style> <![endif]--> <div class="container" > <!-- 移动的婚车 --> <div class="car"> <img class="u-car" class="lazy" data-src="images/moveCar.png"/> <img class="u-dog" class="lazy" data-src="images/ballon.gif"/> </div> <!-- 首页 --> <div class="home"> <div class="nav"> <ul> <li><span id="to-picture">相册</span></li> <li><span id="to-invitation">邀请函</span></li> <li><span id="to-wall">祝福墙</span></li> <li><span id="to-address">婚礼地点</span></li> </ul> </div> </div> <!-- 邀请函 --> <div class="invitation"> <!--<span id="invite-return" class="u-return">返回首页</span>--> <img class="u-return" id="invite-return" class="lazy" data-src="images/btn_return.png"/> <div class="invitation-content"></div> </div> <!-- 婚纱照 --> <div class="wedding-photos"> <div><img class="lazy" data-src="images/photo1.jpg"/></div> <div><img class="lazy" data-src="images/photo2.jpg"/></div> <div><img class="lazy" data-src="images/photo3.jpg"/></div> <div><img class="lazy" data-src="images/photo4.jpg"/></div> <div><img class="lazy" data-src="images/photo5.jpg"/></div> </div> <!-- 场景六 --> <div class="six-box"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> <!-- 场景七祝福墙内容 --> <div class="seven-box"> <img id="blessing-return" class="u-return" class="lazy" data-src="images/btn_return.png"/> <div class="clickMe">点我送祝福</div> <div class="seven-content"> <div class="note-a1"></div> <div class="note-a2"></div> <div class="note-a3"></div> <div class="note-a4"></div> <div class="note-a5"></div> <div class="note-a6"></div> <div class="note-a7"></div> <div class="note-a8"></div> <div class="note-a9"></div> <div class="note-a10"></div> <div class="note-a11"></div> <div class="note-a12"></div> <div class="note-1">一定要幸福哦~</div> <div class="note-2">祝你们白头偕老!</div> <div class="note-3">早生贵子~</div> <div class="note-4">新婚快乐~</div> <div class="note-5">生个宝宝认我做干妈!</div> <div class="note-6">喜结良缘O(∩_∩)O哈哈哈~</div> <div class="note-1">一定要幸福哦~</div> <div class="note-2">祝你们白头偕老!</div> <div class="note-3">早生贵子~</div> <div class="note-4">新婚快乐~</div> <div class="note-5">生个宝宝认我做干妈!</div> <div class="note-6">喜结良缘O(∩_∩)O哈哈哈~</div> </div> </div> <!-- 照片墙 --> <div class="picture-wall"> <img class="u-return" id="picture-return" class="lazy" data-src="images/btn_return.png"/> <div class="pic0 picRow"><img class="lazy" data-src="images/pic0.jpg"/></div> <div class="pic1 picRow"><img class="lazy" data-src="images/pic1.jpg"/></div> <div class="pic2 picCol"><img class="lazy" data-src="images/pic2.jpg"/></div> <div class="pic3 picCol"><img class="lazy" data-src="images/pic3.jpg"/></div> <div class="pic4 picCol"><img class="lazy" data-src="images/pic4.jpg"/></div> <div class="pic5 picCol"><img class="lazy" data-src="images/pic5.jpg"/></div> <div class="pic6 picRow"><img class="lazy" data-src="images/pic6.jpg"/></div> <div class="pic7 picRow"><img class="lazy" data-src="images/pic7.jpg"/></div> <div class="pic8 picRow"><img class="lazy" data-src="images/pic8.jpg"/></div> <div class="pic9 picCol"><img class="lazy" data-src="images/pic9.jpg"/></div> <div class="pic10 picCol"><img class="lazy" data-src="images/pic10.jpg"/></div> <div class="pic11 picRow"><img class="lazy" data-src="images/pic11.jpg"/></div> </div> <!-- 婚礼地址 --> <div class="address"> <img class="u-return" id="address-return" class="lazy" data-src="images/btn_return.png"/> <img class="u-love" class="lazy" data-src="images/love.gif"/> <img class="lazy" data-src="images/address.jpg"/> </div> </div> <!-- 遮罩层 --> <div class="mask"></div> <div class="pop-box"> <h2>送上祝福语</h2> <textarea id="write">写上您的祝福吧~</textarea> <div class="u-sure" id="uSure">确定</div> </div> <!-- 背景音乐 --> <embed class="lazy" data-src="http://www.youxiren.com/upload/image/20140102/ezjzw.mp3" width="0" height="0" autostart="true" loop="true"> <object data="http://www.youxiren.com/upload/image/20140102/ezjzw.mp3" type="application/x-mplayer2" width="0" height="0"> <param name="class="lazy" data-src" value="music.mp3"> <param name="autostart" value="1"> <param name="playcount" value="0"> </object> <script type="text/javascript" class="lazy" data-src="js/jquery-1.10.2.js"></script> <script type="text/javascript" class="lazy" data-src="js/jquery-ui-1.10.2.custom.js"></script> <script type="text/javascript" class="lazy" data-src="js/index.js"></script> </body> </html>
2.js代码
var sceneObject = { init: function(){ this._enterCar(); this._enterInvitation(); this._enterAlbum(); this._enterWall(); this._addBlessing(); this._searchAddress(); }, _enterCar: function(){ initCar(); $(window).resize(function(){ setCarPosition(); }) }, _enterInvitation: function(){ var $home = $(".home"), $toInvitation = $("#to-invitation"), $invitation = $(".invitation"), $invitationCt = $(".invitation-content"), $inviteReturn = $("#invite-return"); $toInvitation.click(function(){ $home.fadeOut(); $invitation.fadeIn(); $invitationCt.animate({"top": "0"},function(){ $inviteReturn.fadeIn(); }); }) $inviteReturn.click(function(){ $invitationCt.css({"top": "-540px"}); $invitation.fadeOut(function(){ $inviteReturn.fadeOut(); $home.fadeIn(600); }); }) }, _enterAlbum: function(){ var $home = $(".home"), $toPicture = $("#to-picture"), $pictureWall = $(".picture-wall"), timer; $toPicture.click(function(){ $home.fadeOut(function(){ $pictureWall.fadeIn(); autoPicWall(); timer = setInterval(autoPicWall,4000); }); }) $("#picture-return").click(function(){ clearInterval(timer); picPage = 0; $pictureWall.fadeOut(function(){ $home.fadeIn(); }) }) }, _enterWall: function(){ var $home = $(".home"), $uEnter = $("#to-wall"); $uEnter.click(function(){ $home.hide(); setTimeout(scene6,400); }) }, _addBlessing: function(){ var $home = $(".home"), $sevenDiv = $(".seven-content div"), $clickMe = $(".clickMe"), $mask = $(".mask"), $popBox = $(".pop-box"), $write = $("#write"), $uSure = $("#uSure"), $sevenContent = $(".seven-content"); draggableNote(); $clickMe.click(function(){ $write.val("送上您的祝福吧~"); $mask.fadeIn(); $popBox.animate({top: "50%"}); }) $write.focus(function(){ var _val = $(this).val(); if(_val == "送上您的祝福吧~"){ $(this).val(""); } }) $write.blur(function(){ var _val = $(this).val(); if(_val.length == 0){ $(this).val("送上您的祝福吧~"); } }) $uSure.click(function(){ var _writeVal = $write.val(), _randomNum = Math.ceil(Math.random()*6); if(_writeVal != "送上您的祝福吧~"){ var _div = '<div class="note-'+_randomNum+'">'+_writeVal+'</div>'; $sevenContent.append(_div); defineSevenDiv($sevenContent.find("div:last")); $popBox.animate({top: "-300px"},function(){ $mask.fadeOut(); draggableNote(); }); }else{ alert("请输入祝福语!"); } }) $("#blessing-return").click(function(){ $(".seven-box").fadeOut(function(){ $home.fadeIn(); }) }) }, _searchAddress: function(){ var $home = $(".home"), $toAddress = $("#to-address"); $address = $(".address"), $addressReturn = $("#address-return"); $toAddress.click(function(){ $home.fadeOut(); $address.fadeIn(); }) $addressReturn.click(function(){ $address.fadeOut(); $home.fadeIn(); }) } } function initCar(){ var $home = $(".home"); setCarPosition(); setTimeout(function(){ $home.fadeIn(); },6500); } function setCarPosition(){ var $car = $(".car"), wWidth = $(window).width(), wHeight = $(window).height(), carWidth = $car.height(), carHeight = $car.height(); $car.css({top:wHeight - carHeight - 100}); $car.animate({left: wWidth - carWidth + 100},8000).fadeOut(); } var picPage = 0, picLeft, picTop; function autoPicWall(){ var $pictureWallPic = $(".picture-wall div"), $own = $pictureWallPic.eq(picPage), isBig = $own.hasClass("bigCenter"), hasClassPicRow = $own.hasClass("picRow"); becomeBig($own,hasClassPicRow); setTimeout(function(){becomeSmall($own,hasClassPicRow);},2000); if(picPage < $pictureWallPic.length - 1){ picPage++; }else if(picPage == $pictureWallPic.length - 1){ picPage = 0; } } function becomeBig($own,hasClassPicRow){ var $mask = $(".mask"), pictureWallWidth = $(".picture-wall").width(), pictureWallHeight = $(".picture-wall").height(); picLeft = $own.css("left"); picTop = $own.css("top"); $own.toggleClass("bigCenter"); $mask.fadeIn(); if(hasClassPicRow){ for(var i = 120; i < 720; i+=20){ $own.find("img").animate({"width": i+"px", "height": i/1.5+"px"},2); $own.animate({"left": (pictureWallWidth-i)/2+"px", "top": (pictureWallHeight-i/1.5)/2+"px"},2); } }else{ for(var i = 80; i < 480; i+=20){ $own.find("img").animate({"width": i+"px", "height": i*1.5+"px"},2); $own.animate({"left": (pictureWallWidth-i)/2+"px", "top": (pictureWallHeight-i*1.5)/2+"px"},2); } } } function becomeSmall($own,hasClassPicRow){ var $mask = $(".mask"), pictureWallWidth = $(".picture-wall").width(), pictureWallHeight = $(".picture-wall").height(); if(hasClassPicRow){ for(var i = 720; i >= 120; i-=40){ $own.find("img").animate({"width": i+"px", "height": i/1.5+"px"},2); $own.animate({"left": (pictureWallWidth-i)/2+"px", "top": (pictureWallHeight-i/1.5)/2+"px"},2); } }else{ for(var i = 480; i >= 80; i-=40){ $own.find("img").animate({"width": i+"px", "height": i*1.5+"px"},2); $own.animate({"left": (pictureWallWidth-i)/2+"px", "top": (pictureWallHeight-i*1.5)/2+"px"},2); } } $own.animate({"left": picLeft, "top": picTop},400,function(){ $mask.fadeOut(); $own.toggleClass("bigCenter"); }); } var colCount = 4, rowCount = 4, $sixBox; function scene6(){ $sixBox = $(".six-box"); $sixBox.fadeIn(); scatter(); setTimeout(together,100); setTimeout(scene7,2000); } function together(){ var $sixDiv = $sixBox.find("div"), sixDivWidth = $sixDiv.width(), sixDivHeight = $sixDiv.height(), sixBoxWidth = $sixBox.width(), sixBoxHeight = $sixBox.height(); $sixDiv.each(function(){ var _index = $(this).index(), col = _index%colCount, row = Math.floor(_index/rowCount), cssLeft = sixBoxWidth/2 - colCount/2*sixDivWidth + col*sixDivWidth, cssTop = sixBoxHeight/2 - rowCount/2*sixDivHeight + row*sixDivHeight, divLeft = -col*sixDivWidth, divTop = -row*sixDivHeight; $(this).animate({"left": cssLeft,"top": cssTop-100},800); }) } function scatter(){ var $sixDiv = $sixBox.find("div"), sixDivWidth = $sixDiv.width(), sixDivHeight = $sixDiv.height(), sixBoxWidth = $sixBox.width(), sixBoxHeight = $sixBox.height(); $sixDiv.each(function(){ var _index = $(this).index(), col = _index%colCount, row = Math.floor(_index/rowCount), cssLeft = (col-1)*(sixBoxWidth+sixDivWidth)- sixDivWidth, cssTop = (row-1)*(sixBoxHeight+sixDivHeight)- sixDivWidth, divLeft = -col*sixDivWidth, divTop = -row*sixDivHeight; $(this).css({"left": cssLeft,"top": cssTop, "background-position": divLeft+"px "+divTop+"px"}) }) } function scene7(){ var $sevenDiv = $(".seven-content div"), $sevenBox = $(".seven-box"); $sixBox.hide(); $sevenBox.fadeIn(1000); $sevenDiv.each(function(){ defineSevenDiv($(this)); }) } function defineSevenDiv($own){ var _obj = defineRandom(); $own.css({"transform":"rotate("+_obj.rotate+"deg)"}); $own.animate({left: _obj.left+"px",top: _obj.top+"px"}); } function defineRandom(){ var randomLeft = Math.floor(680*(Math.random())) + 30, randomTop = Math.floor(400*Math.random()) + 30, randomRotate = 20 - Math.floor(40*Math.random()); return { left: randomLeft, top: randomTop, rotate:randomRotate } } function draggableNote(){ $(".seven-content div").draggable({ containment: $(".seven-content"), zIndex: 2700, start: function(){ $(this).css({"transform":"rotate(0deg)","cursor": "crosshair"}); }, stop: function(){ var _obj = defineRandom(); $(this).css({"transform":"rotate("+_obj.rotate+"deg)","cursor": "pointer"}); } }) } $(function(){ sceneObject.init(); })
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注编程网行业资讯频道,感谢您对编程网的支持。
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341