首頁 >web前端 >css教學 >css3實作響應式滑動選單的完整程式碼

css3實作響應式滑動選單的完整程式碼

不言
不言原創
2018-08-30 10:49:123192瀏覽

本篇文章给大家带来的内容是关于css3实现响应式滑动菜单的完整代码,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

<!DOCTYPE html>
 <html>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
         <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
         <meta name="viewport" content="width=device-width, initial-scale=1.0">
         <title>CSS3滑动动画菜单DEMO演示</title>
         <link rel="stylesheet" type="text/css" href="css/default.css" />
         <link rel="stylesheet" type="text/css" href="css/component.css" />
         <script src="js/modernizr.custom.js"></script>
     </head>
     <body>
         <div>
             <header>
                 <h1>CSS3响应式滑动菜单</h1>
             </header>
             <div class="main clearfix">
                 <nav id="menu">
                     <ul>
                         <li>
                             <a href="#">
                                 <span>
                                     <i aria-hidden="true"></i>
                                 </span>
                                 <span>Home</span>
                             </a>
                         </li>
                         <li>
                             <a href="#">
                                 <span>
                                     <i aria-hidden="true"></i>
                                 </span>
                                 <span>Services</span>
                             </a>
                         </li>
                         <li>
                             <a href="#">
                                 <span>
                                     <i aria-hidden="true"></i>
                                 </span>
                                 <span>Portfolio</span>
                             </a>
                         </li>
                         <li>
                             <a href="#">
                                 <span>
                                     <i aria-hidden="true"></i>
                                 </span>
                                 <span>Blog</span>
                             </a>
                         </li>
                         <li>
                             <a href="#">
                                 <span>
                                     <i aria-hidden="true"></i>
                                 </span>
                                 <span>The team</span>
                             </a>
                         </li>
                         <li>
                             <a href="#">
                                 <span>
                                     <i aria-hidden="true"></i>
                                 </span>
                                 <span>mail</span>
                             </a>
                         </li>
                     </ul>
                 </nav>
 <div style="text-align:center;clear:both"><br>
 <script src="/gg_bd_ad_720x90.js"  type="text/javascript"></script><script src="/follow.js"  type="text/javascript"></script></div>
             </div>
         </div><!-- /container -->
         <script>
            var changeClass = function (r,className1,className2) {
                 var regex = new RegExp("(?:^|\\s+)" + className1 + "(?:\\s+|$)");
                 if( regex.test(r.className) ) {
                     r.className = r.className.replace(regex,&#39; &#39;+className2+&#39; &#39;);
                 }
                 else{
                     r.className = r.className.replace(new RegExp("(?:^|\\s+)" + className2 + "(?:\\s+|$)"),&#39; &#39;+className1+&#39; &#39;);
                 }
                 return r.className;
             };
            var menuElements = document.getElementById(&#39;menu&#39;);
             menuElements.insertAdjacentHTML(&#39;afterBegin&#39;,&#39;<button  type="button" id="menutoggle"  aria-hidden="true"><i aria-hidden="true">  </i> Menu</button>&#39;);
            document.getElementById(&#39;menutoggle&#39;).onclick = function() {
                 changeClass(this, &#39;navtoogle active&#39;, &#39;navtoogle&#39;);
             }
         </script>
     </body>
 </html>

相关推荐:

CSS3响应式滑动菜单_html/css_WEB-ITnose

JS+CSS实现简单滑动门(滑动菜单)效果_javascript技巧

以上是css3實作響應式滑動選單的完整程式碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn