示例代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>网站 - 首页</title>
<style>
* {
margin: 0;
padding: 0;
}
nav {
background: #000;
height: 30px;
width: 100%;
color: #fff;
position: fixed;
top: 0;
left: 0;
}
</style>
</head>
<body>
<nav>
这是顶部导航
</nav>
</body>
</html>