jQuery實現仿百度首頁滑動伸縮展開的添加服務效果代碼,jquery首頁

來源:互聯網
上載者:User

jQuery實現仿百度首頁滑動伸縮展開的添加服務效果代碼,jquery首頁

本文執行個體講述了jQuery實現仿百度首頁滑動伸縮展開的添加服務效果代碼。分享給大家供大家參考。具體如下:

這是一款仿百度首頁jQuery滑動伸縮展開的添加服務效果,其實是一款伸縮菜單,只不過這個菜單有點特別,只從一頭向另一頭伸展出去,菜單的伸縮效果平滑,設計精美。

運行效果如下:

線上示範地址如下:

http://demo.jb51.net/js/2015/js-f-baidu-index-show-serv-style-codes/

具體代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>添加服務</title><style>*{padding:0;margin:0;font:12px/26px "微軟雅黑";}a,a:hover{text-decoration:none;color:#ccc;}dl{margin:0 auto;border:1px solid #fff;float:left;position:absolute;left:50%;color:#ccc;margin:100px 0 100px -45px ;overflow:hidden;}dl.open{margin-left:-200px;}dl.open dt{background:url(images/s_add_all_3f6f39e5.png) 0 0 no-repeat;}dl dt{width:94px;height:30px;line-height:30px;text-align:center;cursor:pointer;position:relative;z-index:10;float:left; background:#fff;}dl dd{display:none;height:28px;float:left;}dl dd a{float:left;display:block;height:28px;line-height:28px;padding:0 15px 0 35px;position:relative;left:-300px;border-top:1px solid #E5E5E5;border-bottom:1px solid #E5E5E5;background:url(images/s_add_all_3f6f39e5.png) no-repeat;}dl dd .nav{background-position:13px -35px;}dl dd .hot{background-position:13px -61px;}dl dd .app{background-position:13px -87px;}dl dd .fresh{background-position:13px -113px;border-right:1px solid #E5E5E5;}dl dd .nav:hover{background-position:-104px -35px;}dl dd .hot:hover{background-position:-104px -61px;}dl dd .app:hover{background-position:-104px -87px;}dl dd .fresh:hover{background-position:-104px -113px;}</style></head><body><dl><dt id="add">+添加服務</dt><dd id="con"><a class="nav" href="#">導航</a><a class="hot" href="#">即時熱點</a><a class="app" href="#">應用</a><a class="fresh" href="#">新鮮事</a></dd></dl></body><script type="text/javascript" src="jquery-1.6.2.min.js"></script><script>window.onload = function(){  var Close = function(event){       $('dd a').animate({left:-400});  setTimeout('$("dl").css("margin-left",-45);$("dl").removeClass("open")',300)     }; var Open = function(event){  $("dd").show();  var dl_W=$("dl").width();  $("dl").addClass("open").css("margin-left",-dl_W/2);   $('dd a').animate({left: 0},300);   Stop(event); }; var Stop = function(event){  e = event || window.event;  if(e.stopPropagation){   e.stopPropagation();  }else {   e.cancelBubble = true;  } }; $(document).bind('click', Close); $('dt').bind('click',Open); $('dd').bind('click',Stop);};</script></html>

希望本文所述對大家的jQuery程式設計有所協助。

聯繫我們

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