jquery製作滑動面板

來源:互聯網
上載者:User

標籤:jquery製作滑動面板   滑動面板製作   點擊圖片進行隱藏   


【web開發】☆★之jquery製作滑動面板


項目開發中,我們有時候需要點擊某個按鈕出現一個面板,在面板上有我們需要的一些操作,或者是圖片。ok!如下簡單製作滑動面板效果:


650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/41/20/wKioL1PQ3avhPBiNAAC5niNARIk236.jpg" title="1.png" alt="wKioL1PQ3avhPBiNAAC5niNARIk236.jpg" />


<!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=gb2312" /><title>無標題文檔</title><script type="text/javascript" src="jQuery/jquery-1.6.2.js"></script><script type="text/javascript"> $(document).ready(function(){ $(".box a").click(function(){ /*slideToggle()這個方法,如果被選元素是可見的,則隱藏這些元素,如果被選元素是隱藏的,則顯示這些元素。*/       $(".one").slideToggle();   /*   oggleClass() 對設定或移除被選元素的一個或多個類進行切換。   該方法檢查每個元素中指定的類。如果不存在則添加類,如果已設定則刪除之。這就是所謂的轉場效果。   */   $(this).toggleClass("active"); });        $(".box p").hover(function(){    $(this).toggleClass("hover")   });   });</script><style type="text/css">*{padding:0;margin:0;}body{font-size:12px;}a{text-decoration:none;color:#000066;font-family:"宋體";}.box{width:500px;margin:0 auto;}.one{height:200px;background:url(images/2.png) no-repeat ;display:none;}.box p{border-top:5px solid #333333;background:url(images/1.png) no-repeat top;}/*將行內元素A寫的和圖片長度和高度差不多*/.box p a{display:block;width:140px;height:40;line-height:40px;background:url(images/3.png) no-repeat right 10px;  text-align:center;margin:0 auto;font-size:14px;font-weight:bolder;padding-right:10px;}/*註冊一個新的class,當我們點擊這個a時,將這個註冊號的class添加到a中*/.box p a.active{background:url(images/4.png) no-repeat right 12px;}.box p.hover{background:url(images/5.png) no-repeat top}</style></head><body><div class="box"><div class="one"></div><p> <a href="#">點 擊</a></p></div></body></html>


ok,這個功能在項目中還是很實用的,尤其是操作按鈕過多一致排開的話會導致頁面美觀度不足,採用這個方法,效果十分明顯!


源碼下載:滑動面板製作

本文出自 “諾言永遠依戀小柴、、、” 部落格,請務必保留此出處http://1936625305.blog.51cto.com/6410597/1529810

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.