Jquery--仿製360右下角快顯視窗

來源:互聯網
上載者:User

標籤:style   c   class   blog   code   java   

原文:Jquery--仿製360右下角快顯視窗


先發瀏覽器,給大家看。

要實現這樣的效果,按照思路,第一步,寫好CSS布局,將圖片放到瀏覽器右下角的位置

CSS代碼很靈活,我寫的只是簡單的一種而已,僅供參考:

<style type="text/css">body{margin:0;      padding:0;      height:100%;      overflow:auto;      }.bottomshow{     position:fixed;     bottom:-320px;     right:0;     width:522px;/*圖片的寬度*/     height:320px;/*圖片的高度*/}</style>

第二步,要考慮寫Jquery動畫,其實我首先想到的是將.bottomshow這個DIV給出style=“display:none”,然後在Jquery(.bottomshow).show(‘slow‘)但是這種方式無法改變動畫出來的方向,於是我放棄了。隨後選著了animate()先將bottom預設設定為-320px剛好是圖片的高度,所以圖片就在瀏覽器的下部的外面,這時候通過animate({bottom:‘0px’},‘slow’)就做到了從下往上彈出360效果,Jquery代碼如下,

<script src="../scripts/jquery-1.3.1.js" type="text/javascript"></script><script type="text/javascript">//等待dom元素載入完畢.function showbottom(){                     $(".bottomshow").animate({bottom:"0px"},‘slow‘);    }$(document).ready(function(){                           setTimeout(‘showbottom()‘,3000);                                 })</script>

第三步就要考慮廣告是可以關閉的,點擊圖片右上方的X就可以關閉,這時候就要用到 img  map click了。具體用法請參考代碼理解:

img map:

<div class="bottomshow"><img src="images/360.jpg" border="0" usemap="#planetmap" /><map name="planetmap" id="planetmap">  <area shape="rect" coords="450,0,520,20" href="javascript:void(0)" onclick="bottomclose()" alt="Sun" /></map></div>

加入href主要是讓滑鼠放上去變手型,map加上style=“cursor:pointer“是不起作用的。

之後在寫close():

function bottomclose(){                     $(".bottomshow").animate({bottom:"-320px"},‘slow‘);    }

最後如果圖片廣告需要跳轉連結,只需要Jquery選擇到此圖片加入onclick連結即可。
代碼尚不成熟,歡迎吐槽。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.