在本教程中,您将使用 JavaScript 和 CSS 创建可扩展的侧面导航菜单。最终产品如下图所示:
1. 创建标记
首先,让我们为侧边菜单添加一些标记:
<div id="sideNavigation" class="sidenav"> <a href="#" class="close-btn">×</a> <a href="#">About</a> <a href="#">Features</a> <a href="#">Contact Us</a> </div> <nav class="topnav"> <a href="#" class="ham-icon"> <svg width="30" height="30" id="icoOpen"> <path d="M0,5 30,5" stroke="#000" stroke-width="5"/> <path d="M0,14 30,14" stroke="#000" stroke-width="5"/> <path d="M0,23 30,23" stroke="#000" stroke-width="5"/> </svg> </a> </nav> <section id="main"> <h1>This Side Navigation Menu Looks Good!</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </section>登录后复制
本文地址:http://ezhuoer.com