jQuery仿天猫完美加入购物车
生活随笔
收集整理的這篇文章主要介紹了
jQuery仿天猫完美加入购物车
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
轉(zhuǎn)載自:http://www.iteye.com/topic/1138064
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery仿天貓完美加入購物車</title><meta name="keywords" content="jquery購物車,加入購物車" /><meta name="description" content="jquery加入購物車帥氣效果,和天貓、聚美優(yōu)品類似" /><link rel="stylesheet" type="text/css" href="http://www.sucaihuo.com/jquery/css/common.css" /><link rel="stylesheet" type="text/css" href="css/demo.css" /></head><body><div class="head"><div class="head_inner"><a class="logo" href="http://www.sucaihuo.com"><img alt="素材火logo" src="http://www.sucaihuo.com/Public/images/logo.jpg"></a></div></div><div class="container"><h2 class="title"><a href="http://www.sucaihuo.com/jquery/demo/1/">jQuery仿天貓完美加入購物車</a></h2><div class="demo clearfix"><div class="per"><img src="images/1.jpg" width="180" height="240" alt="圖片二"/><h3>¥<span>259.00</span></h3><div class="title">春款真皮坡跟大碼單鞋內(nèi)增高女士鞋子</div><a href="javascript:void(0);" class="button orange addcart">加入購物車</a></div><div class="per"><img src="images/2.jpg" width="180" height="240" alt="圖片二"/><h3>¥<span>136.00</span></h3><div class="title">韓國代購情侶棉衣棉服女款韓版羊羔毛大衣</div><a href="javascript:void(0);" class="button orange addcart">加入購物車</a></div><div class="per"><img src="images/3.jpg" width="180" height="240" alt="圖片三"/><h3>¥<span>¥728.00</span></h3><div class="title">冬季運(yùn)動情侶羽絨棉馬甲男士薄馬甲</div><a href="javascript:void(0);" class="button orange addcart">加入購物車</a></div><div class="per"><img src="images/4.jpg" width="180" height="240" alt="圖片四"/><h3>¥<span>119.00</span></h3><div class="title">原創(chuàng)-城市簡約文藝純色棉麻新中式小立領(lǐng)</div><a href="javascript:void(0);" class="button orange addcart">加入購物車</a></div></div></div><div class="cart-sidebar"><div class="cart"><i id="icon-cart"></i><span>購物車</span></div></div><div id="tip">成功加入購物車!</div><div class="foot">Powered by sucaihuo.com 本站皆為作者原創(chuàng),轉(zhuǎn)載請注明原文鏈接:<a href="http://www.sucaihuo.com" target="_blank">www.sucaihuo.com</a></div><script type="text/javascript" src="http://www.sucaihuo.com/Public/js/other/jquery.js"></script><script src="js/jquery.fly.min.js"></script><!--[if lte IE 9]><script src="js/requestAnimationFrame.js"></script><![endif]--><script type="text/javascript">$(function() {var offset = $("#icon-cart").offset();$(".addcart").click(function(event) {var img = $(this).parent().children('img').attr('src');//獲取當(dāng)前點(diǎn)擊圖片鏈接var flyer = $('<img class="flyer-img" src="' + img + '">');//拋物體對象 flyer.fly({start: {left: event.pageX, //拋物體起點(diǎn)橫坐標(biāo) top: event.pageY////拋物體起點(diǎn)縱坐標(biāo) },end: {left: offset.left + 10, //拋物體終點(diǎn)橫坐標(biāo) top: offset.top + 10, //拋物體終點(diǎn)縱坐標(biāo) },onEnd: function() {$("#tip").show().animate({width: '200px'}, 300).fadeOut(500);//成功加入購物車動畫效果this.destory();//銷毀拋物體 }});});});</script></body> </html>dome.css
.demo{width:830px; margin:0 auto} .cart-sidebar{z-index: 1999;width: 35px;color: #FFFFFF;position: fixed;top: 0;right: 0;background: #000000;height:100%;} .cart{color: #fff;text-align:center;line-height: 20px;padding: 200px 0 0 0px;} .cart span{display:block;width:20px;margin:0 auto;} .cart i{width:35px;height:35px;display:block; background:url(../images/cart.png) no-repeat;} #tip{position:fixed; top:300px; right:35px; z-index:10000; width:1px; height:52px; line-height:52px; font-size:20px; text-align:center; color:#fff; background:#360; display:none} .per{float:left; border:1px solid #e0e0e0; text-align:center;padding:10px 0;width:198px;margin-right: 5px} .per .title{ text-align:left;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;width:180px;margin:0 0 10px 10px} .per:hover{border:1px solid #f90} .per h3{line-height:32px; font-size:14px; color:#f30;font-weight:500} .per h3 span{font-size:20px} .flyer-img{display: block;width: 50px;height: 50px;border-radius: 50px;position: fixed;z-index: 9999;}.button {display: inline-block;outline: none;cursor: pointer;text-align: center;text-decoration: none;font: 16px/100% 'Microsoft yahei',Arial, Helvetica, sans-serif;padding: .5em 2em .55em;text-shadow: 0 1px 1px rgba(0,0,0,.3);-webkit-border-radius: .5em; -moz-border-radius: .5em;border-radius: .5em;-webkit-per-shadow: 0 1px 2px rgba(0,0,0,.2);-moz-per-shadow: 0 1px 2px rgba(0,0,0,.2);box-shadow: 0 1px 2px rgba(0,0,0,.2); } /*****加入購物車按鈕****/ .button:hover {text-decoration: none; } .orange {color: #fef4e9;border: solid 1px #da7c0c;background: #f78d1d;background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20));background: -moz-linear-gradient(top, #faa51a, #f47a20);filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20'); } .orange:hover {background: #f47c20;background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));background: -moz-linear-gradient(top, #f88e11, #f06015);filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015'); }jquery.fly.min.js
/*! fly - v1.0.0 - 2014-12-22 * https://github.com/amibug/fly * Copyright (c) 2014 wuyuedong; Licensed MIT */ !function(a){a.fly=function(b,c){var d={version:"1.0.0",autoPlay:!0,vertex_Rtop:20,speed:1.2,start:{},end:{},onEnd:a.noop},e=this,f=a(b);e.init=function(a){this.setOptions(a),!!this.settings.autoPlay&&this.play()},e.setOptions=function(b){this.settings=a.extend(!0,{},d,b);var c=this.settings,e=c.start,g=c.end;f.css({marginTop:"0px",marginLeft:"0px",position:"fixed"}).appendTo("body"),null!=g.width&&null!=g.height&&a.extend(!0,e,{width:f.width(),height:f.height()});var h=Math.min(e.top,g.top)-Math.abs(e.left-g.left)/3;h<c.vertex_Rtop&&(h=Math.min(c.vertex_Rtop,Math.min(e.top,g.top)));var i=Math.sqrt(Math.pow(e.top-g.top,2)+Math.pow(e.left-g.left,2)),j=Math.ceil(Math.min(Math.max(Math.log(i)/.05-75,30),100)/c.speed),k=e.top==h?0:-Math.sqrt((g.top-h)/(e.top-h)),l=(k*e.left-g.left)/(k-1),m=g.left==l?0:(g.top-h)/Math.pow(g.left-l,2);a.extend(!0,c,{count:-1,steps:j,vertex_left:l,vertex_top:h,curvature:m})},e.play=function(){this.move()},e.move=function(){var b=this.settings,c=b.start,d=b.count,e=b.steps,g=b.end,h=c.left+(g.left-c.left)*d/e,i=0==b.curvature?c.top+(g.top-c.top)*d/e:b.curvature*Math.pow(h-b.vertex_left,2)+b.vertex_top;if(null!=g.width&&null!=g.height){var j=e/2,k=g.width-(g.width-c.width)*Math.cos(j>d?0:(d-j)/(e-j)*Math.PI/2),l=g.height-(g.height-c.height)*Math.cos(j>d?0:(d-j)/(e-j)*Math.PI/2);f.css({width:k+"px",height:l+"px","font-size":Math.min(k,l)+"px"})}f.css({left:h+"px",top:i+"px"}),b.count++;var m=window.requestAnimationFrame(a.proxy(this.move,this));d==e&&(window.cancelAnimationFrame(m),b.onEnd.apply(this))},e.destory=function(){f.remove()},e.init(c)},a.fn.fly=function(b){return this.each(function(){void 0==a(this).data("fly")&&a(this).data("fly",new a.fly(this,b))})}}(jQuery);效果演示地址:http://www.sucaihuo.com/jquery/demo/1/
總結(jié)
以上是生活随笔為你收集整理的jQuery仿天猫完美加入购物车的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MultiMC的离线模式启动
- 下一篇: 反向安装jar包到本地仓库和清除本地仓库