您好,登錄后才能下訂單哦!
這篇文章主要講解了jquery+css3如何實現經典彈出層效果,內容清晰明了,對此有興趣的小伙伴可以學習一下,相信大家閱讀完之后會有幫助。
可能出現的情況
1)一列都有,按順序彈出對應的彈出層
2)只有單個一個彈出層
3)不按順序不按規律隨機彈出層
jquery 彈出層 解決 第一種情況
參考資料
移動端之“CSS3多動畫彈框”
引入jquery
JS代碼 這里關閉用的css3效果實現
<script type="text/javascript"> var w,h,className; function getSrceenWH(){ w = $(window).width(); h = $(window).height(); $('#dialogBg').width(w).height(h); } window.onresize = function(){ getSrceenWH(); } $(window).resize(); $(function(){ getSrceenWH(); //顯示彈框 $('.solution_class a').click(function(){ className = $(this).attr('class'); $('#dialogBg').fadeIn(300); $('#dialog').removeAttr('class').addClass('animated '+className+'').fadeIn(); }); //關閉彈窗 $('.claseDialogBtn,#dialogBg').click(function(){ $('#dialogBg').fadeOut(300,function(){ $('#dialog').addClass('bounceOutUp').fadeOut(); }); }); }); </script>
HTML
<div id="dialogBg"></div> <div id="dialog" class="animated"> <div class="dialogTop"> <a href="javascript:;" rel="external nofollow" class="claseDialogBtn">關閉</a> </div> </div>
css
/*遮罩層*/ .animated{ -webkit-animation-duration:1.4s; animation-duration:1.4s; -webkit-animation-fill-mode:both; animation-fill-mode:both } @-webkit-keyframes bounceIn{ 0%{ opacity:0; -webkit-transform:scale(.3); transform:scale(.3) } 50%{ opacity:1; -webkit-transform:scale(1.05); transform:scale(1.05) } 70%{ -webkit-transform:scale(.9); transform:scale(.9) } 100%{ opacity:1; -webkit-transform:scale(1); transform:scale(1) } } @keyframes bounceIn{ 0%{ opacity:0; -webkit-transform:scale(.3); -ms-transform:scale(.3); transform:scale(.3) } 50%{ opacity:1; -webkit-transform:scale(1.05); -ms-transform:scale(1.05); transform:scale(1.05) } 70%{ -webkit-transform:scale(.9); -ms-transform:scale(.9); transform:scale(.9) } 100%{ opacity:1; -webkit-transform:scale(1); -ms-transform:scale(1); transform:scale(1) } } .bounceIn{ -webkit-animation-name:bounceIn; animation-name:bounceIn } @-webkit-keyframes bounceInDown { 0% { opacity: 0; -webkit-transform: translateY(-2000px); transform: translateY(-2000px); } 60% { opacity: 1; -webkit-transform: translateY(30px); transform: translateY(30px); } 80% { -webkit-transform: translateY(-10px); transform: translateY(-10px); } 100% { -webkit-transform: translateY(0); transform: translateY(0); } } @keyframes bounceInDown { 0% { opacity: 0; -webkit-transform: translateY(-2000px); -ms-transform: translateY(-2000px); transform: translateY(-2000px); } 60% { opacity: 1; -webkit-transform: translateY(30px); -ms-transform: translateY(30px); transform: translateY(30px); } 80% { -webkit-transform: translateY(-10px); -ms-transform: translateY(-10px); transform: translateY(-10px); } 100% { -webkit-transform: translateY(0); -ms-transform: translateY(0); transform: translateY(0); } } .bounceInDown { -webkit-animation-name: bounceInDown; animation-name: bounceInDown; } @-webkit-keyframes bounceOutUp { 0% { -webkit-transform: translateY(0); transform: translateY(0); } 20% { opacity: 1; -webkit-transform: translateY(20px); transform: translateY(20px); } 100% { opacity: 0; -webkit-transform: translateY(-2000px); transform: translateY(-2000px); } } @keyframes bounceOutUp { 0% { -webkit-transform: translateY(0); -ms-transform: translateY(0); transform: translateY(0); } 20% { opacity: 1; -webkit-transform: translateY(20px); -ms-transform: translateY(20px); transform: translateY(20px); } 100% { opacity: 0; -webkit-transform: translateY(-2000px); -ms-transform: translateY(-2000px); transform: translateY(-2000px); } } .bounceOutUp { -webkit-animation-name: bounceOutUp; animation-name: bounceOutUp; } @-webkit-keyframes rollIn { 0% { opacity: 0; -webkit-transform: translateX(-100%) rotate(-120deg); transform: translateX(-100%) rotate(-120deg); } 100% { opacity: 1; -webkit-transform: translateX(0px) rotate(0deg); transform: translateX(0px) rotate(0deg); } } @keyframes rollIn { 0% { opacity: 0; -webkit-transform: translateX(-100%) rotate(-120deg); -ms-transform: translateX(-100%) rotate(-120deg); transform: translateX(-100%) rotate(-120deg); } 100% { opacity: 1; -webkit-transform: translateX(0px) rotate(0deg); -ms-transform: translateX(0px) rotate(0deg); transform: translateX(0px) rotate(0deg); } } .rollIn { -webkit-animation-name: rollIn; animation-name: rollIn; } @-webkit-keyframes flipInX { 0% { -webkit-transform: perspective(400px) rotateX(90deg); transform: perspective(400px) rotateX(90deg); opacity: 0; } 40% { -webkit-transform: perspective(400px) rotateX(-10deg); transform: perspective(400px) rotateX(-10deg); } 70% { -webkit-transform: perspective(400px) rotateX(10deg); transform: perspective(400px) rotateX(10deg); } 100% { -webkit-transform: perspective(400px) rotateX(0deg); transform: perspective(400px) rotateX(0deg); opacity: 1; } } @keyframes flipInX { 0% { -webkit-transform: perspective(400px) rotateX(90deg); -ms-transform: perspective(400px) rotateX(90deg); transform: perspective(400px) rotateX(90deg); opacity: 0; } 40% { -webkit-transform: perspective(400px) rotateX(-10deg); -ms-transform: perspective(400px) rotateX(-10deg); transform: perspective(400px) rotateX(-10deg); } 70% { -webkit-transform: perspective(400px) rotateX(10deg); -ms-transform: perspective(400px) rotateX(10deg); transform: perspective(400px) rotateX(10deg); } 100% { -webkit-transform: perspective(400px) rotateX(0deg); -ms-transform: perspective(400px) rotateX(0deg); transform: perspective(400px) rotateX(0deg); opacity: 1; } } .flipInX { -webkit-backface-visibility: visible !important; -ms-backface-visibility: visible !important; backface-visibility: visible !important; -webkit-animation-name: flipInX; animation-name: flipInX; } /*------------------- 華麗分割線 -----------------------*/ /*------------------- 華麗分割線 -----------------------*/ #dialogBg { width: 100%; height: 100%; background-color: #000000; opacity: .8; filter: alpha(opacity=60); position: fixed; top: 0; left: 0; z-index: 9999; display: none; } #dialog { width: 800px; height: 600px; margin: 0 auto; display: none; background-color: #ffffff; position: fixed; top: 50%; left: 50%; margin: -300px 0 0 -400px; z-index: 10000; border: 1px solid #ccc; border-radius: 10px; -webkit-border-radius: 10px; box-shadow: 3px 2px 4px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 3px 2px 4px rgba(0, 0, 0, 0.2); } .dialogTop { width: 90%; margin: 0 auto; border-bottom: 1px dotted #ccc; letter-spacing: 1px; padding: 10px 0; text-align: right; } .dialogIco { width: 50px; height: 50px; position: absolute; top: -25px; left: 50%; margin-left: -25px; } .editInfos { padding: 15px 0; } .editInfos li { width: 90%; margin: 8px auto auto; text-align: center; } .ipt { border: 1px solid #ccc; padding: 5px; border-radius: 3px; -webkit-border-radius: 3px; box-shadow: 0 0 3px #ccc inset; -webkit-box-shadow: 0 0 3px #ccc inset; margin-left: 5px; } .ipt:focus { outline: none; border-color: #66afe9; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6); -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6); } .submitBtn{width:90px;height:30px;line-height:30px;font-family:"微軟雅黑","microsoft yahei";cursor:pointer;margin-top:10px;display:inline-block;border-radius:5px;-webkit-border-radius:5px;text-align:center;background-color:#428bca;color:#fff;box-shadow: 0 -3px 0 #2a6496 inset;-webkit-box-shadow: 0 -3px 0 #2a6496 inset;}
看完上述內容,是不是對jquery+css3如何實現經典彈出層效果有進一步的了解,如果還想學習更多內容,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。