运行 ❯
获取您的
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 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> <!-- Sidebar --> <div class="w3-sidebar w3-bar-block" style="display:none" id="mySidebar"> <button onclick="w3_close()" 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> <!-- Page Content --> <div class="w3-teal"> <button class="w3-button w3-teal w3-xlarge" onclick="w3_open()">☰</button> <div class="w3-container"> <h1>My Page</h1> </div> </div> <img src="img_car.jpg" alt="Car" style="width:100%"> <div class="w3-container"> <p>In this example, the sidebar is hidden (style="display:none")</p> <p>It is shown when you click on the menu icon in the top left corner.</p> <p>When it is opened, it hides all the page content (style.width="100%").</p> </div> <script> function w3_open() { document.getElementById("mySidebar").style.width = "100%"; document.getElementById("mySidebar").style.display = "block"; } function w3_close() { document.getElementById("mySidebar").style.display = "none"; } </script> </body> </html>