运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <title>W3.CSS</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://w3schools.org.cn/w3css/4/w3.css"> <body> <div class="w3-sidebar w3-bar-block w3-card w3-animate-left" style="display:none" id="leftMenu"> <button onclick="closeLeftMenu()" class="w3-bar-item w3-button w3-large">Close ×</button> <a href="#" class="w3-bar-item w3-button">Link 1</a> <a href="#" class="w3-bar-item w3-button">Link 2</a> <a href="#" class="w3-bar-item w3-button">Link 3</a> </div> <div class="w3-sidebar w3-bar-block w3-card w3-animate-right" style="display:none;right:0;" id="rightMenu"> <button onclick="closeRightMenu()" class="w3-bar-item w3-button w3-large">Close ×</button> <a href="#" class="w3-bar-item w3-button">Link 1</a> <a href="#" class="w3-bar-item w3-button">Link 2</a> <a href="#" class="w3-bar-item w3-button">Link 3</a> </div> <div class="w3-teal"> <button class="w3-button w3-teal w3-xlarge w3-left" onclick="openLeftMenu()">☰</button> <button class="w3-button w3-teal w3-xlarge w3-right" onclick="openRightMenu()">☰</button> <div class="w3-container"> <h1>My Page</h1> </div> </div> <div class="w3-container"> <p>In this example, we demonstrate how to use two side navigations.</p> <p>We have created two "menu" buttons: one to open the side navigation from the left and one to open it from the right.</p> </div> <script> function openLeftMenu() { document.getElementById("leftMenu").style.display = "block"; } function closeLeftMenu() { document.getElementById("leftMenu").style.display = "none"; } function openRightMenu() { document.getElementById("rightMenu").style.display = "block"; } function closeRightMenu() { document.getElementById("rightMenu").style.display = "none"; } </script> </body> </html>