响应式导航栏实现方式——JavaScript实例

36

简介

一个简单的HTML文档,用于创建一个具有响应式导航栏的网页

预览图

源码内容

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="style.css">
        <script src="script.js"></script>
        <title>响应式导航栏</title>
    </head>
    <body>
        <nav class="nav">
            <div class="nav_logo">Logo</div>
            <a href="#" class="nav_hamburger">
                <span class="nav_hamburger_line"></span>
                <span class="nav_hamburger_line"></span>
                <span class="nav_hamburger_line"></span>
            </a>
            <div class="nav_menu">
                <ul>
                    <li class="nav_menu_link"><a href="#home">home</a></li>
                    <li class="nav_menu_link"><a href="#about">about</a></li>
                    <li class="nav_menu_link"><a href="#contact">contact</a></li>
                </ul>
            </div>
        </nav>
        <div class="bg"></div>
    </body>
</html>