標籤: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