<!DOCTYPE html>
<html>
<head>
<title>W3.CSS(w3cschool.cn)</title>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
<link rel="stylesheet" href="https://7npmedia.w3cschool.cn/w3.css">
</head>
<body>
<div class="w3-bar w3-red">
<a href="#" class="w3-bar-item w3-button">主页</a>
<a href="#" class="w3-bar-item w3-button w3-hide-small">链接 1</a>
<a href="#" class="w3-bar-item w3-button w3-hide-small">链接 2</a>
<a href="#" class="w3-bar-item w3-button w3-hide-small">链接 3</a>
<a href="javascript:void(0)" class="w3-bar-item w3-button w3-right w3-hide-large w3-hide-medium" onclick="myFunction()">☰</a>
</div>
<div id="demo" class="w3-bar-block w3-red w3-hide w3-hide-large w3-hide-medium">
<a href="#" class="w3-bar-item w3-button">链接 1</a>
<a href="#" class="w3-bar-item w3-button">链接 2</a>
<a href="#" class="w3-bar-item w3-button">链接 3</a>
</div>
<div class="w3-container">
<p>在本例中,当显示在平板电脑和移动设备上时,导航栏将被右上角的按钮(☰)替换。单击按钮时,栏中的链接将垂直堆叠。</p>
<p>调整屏幕大小以查看效果。</p>
</div>
<script>
function myFunction() {
var x = document.getElementById("demo");
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");