写一个复杂的html+css+vue的游戏网页代码要求有二级栏目
时间: 2024-03-16 09:43:40 浏览: 19
下面是一个基于Vue的游戏网页的示例代码,包括二级栏目。请注意,这只是一个示例,您可以根据自己的需求进行修改和扩展。
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>游戏网页</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="app">
<header>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li>
<a href="#">游戏分类</a>
<ul>
<li><a href="#">射击游戏</a></li>
<li><a href="#">角色扮演游戏</a></li>
<li><a href="#">策略游戏</a></li>
</ul>
</li>
<li><a href="#">排行榜</a></li>
<li><a href="#">关于我们</a></li>
</ul>
</nav>
</header>
<main>
<h1>{{ pageTitle }}</h1>
<div class="game-list">
<div class="game-item">
<img src="game1.jpg" alt="游戏1">
<h2>游戏1</h2>
<p>这是一款射击游戏</p>
</div>
<div class="game-item">
<img src="game2.jpg" alt="游戏2">
<h2>游戏2</h2>
<p>这是一款角色扮演游戏</p>
</div>
<div class="game-item">
<img src="game3.jpg" alt="游戏3">
<h2>游戏3</h2>
<p>这是一款策略游戏</p>
</div>
</div>
</main>
<footer>
<p>版权所有 © 2021 游戏网页</p>
</footer>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="app.js"></script>
</body>
</html>
```
CSS代码:
```css
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f8f8f8;
}
header {
background-color: #333;
color: #fff;
padding: 10px;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
nav li {
display: inline-block;
margin-right: 20px;
position: relative;
}
nav li:last-child {
margin-right: 0;
}
nav a {
color: #fff;
text-decoration: none;
}
nav ul ul {
display: none;
position: absolute;
top: 100%;
left: 0;
background-color: #333;
padding: 10px;
}
nav ul ul li {
display: block;
margin-right: 0;
}
nav li:hover > ul {
display: block;
}
main {
padding: 20px;
}
h1 {
font-size: 36px;
margin-bottom: 20px;
}
.game-list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.game-item {
flex-basis: calc(33.33% - 20px);
margin-bottom: 20px;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
.game-item img {
max-width: 100%;
height: auto;
margin-bottom: 10px;
}
.game-item h2 {
font-size: 24px;
margin-bottom: 10px;
}
.game-item p {
font-size: 16px;
line-height: 1.5;
margin-bottom: 0;
}
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}
```
Vue代码:
```javascript
var app = new Vue({
el: '#app',
data: {
pageTitle: '所有游戏'
}
});
```