用html+css+js编写一个旅游网站
时间: 2023-08-27 15:05:51 浏览: 141
好的,以下是一个简单的旅游网站的HTML、CSS和JS代码示例,供您参考:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>旅游网站</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>旅游网站</h1>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">旅游路线</a></li>
<li><a href="#">预订</a></li>
<li><a href="#">联系我们</a></li>
</ul>
</nav>
</header>
<main>
<section id="banner">
<h2>发现世界,体验生活</h2>
</section>
<section id="routes">
<h2>热门旅游路线</h2>
<ul>
<li>
<img src="route1.jpg" alt="路线1">
<h3>路线1</h3>
<p>描述1</p>
<a href="#">了解更多</a>
</li>
<li>
<img src="route2.jpg" alt="路线2">
<h3>路线2</h3>
<p>描述2</p>
<a href="#">了解更多</a>
</li>
<li>
<img src="route3.jpg" alt="路线3">
<h3>路线3</h3>
<p>描述3</p>
<a href="#">了解更多</a>
</li>
</ul>
</section>
<section id="booking">
<h2>预订</h2>
<form>
<label for="destination">目的地:</label>
<input type="text" id="destination" name="destination">
<label for="date">出行日期:</label>
<input type="date" id="date" name="date">
<label for="people">出行人数:</label>
<input type="number" id="people" name="people">
<button type="submit">提交</button>
</form>
</section>
</main>
<footer>
<p>版权所有 © 2021 旅游网站</p>
</footer>
<script src="script.js"></script>
</body>
</html>
```
CSS代码:
```css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
}
header {
background-color: #333;
color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
}
nav ul {
list-style: none;
display: flex;
}
nav ul li {
margin-right: 1rem;
}
nav ul li a {
color: #fff;
text-decoration: none;
padding: 0.5rem;
}
#banner {
background-image: url(banner.jpg);
height: 500px;
background-size: cover;
display: flex;
justify-content: center;
align-items: center;
}
#banner h2 {
font-size: 3rem;
color: #fff;
text-align: center;
text-shadow: 2px 2px #333;
}
#routes {
margin: 2rem;
}
#routes h2 {
text-align: center;
margin-bottom: 2rem;
}
#routes ul {
list-style: none;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
}
#routes li {
width: 30%;
margin-bottom: 2rem;
box-shadow: 2px 2px 5px #ccc;
}
#routes img {
width: 100%;
height: 200px;
object-fit: cover;
}
#routes h3 {
text-align: center;
margin-top: 1rem;
}
#routes p {
text-align: center;
margin-bottom: 1rem;
}
#routes a {
display: block;
text-align: center;
background-color: #333;
color: #fff;
text-decoration: none;
padding: 0.5rem;
}
#booking {
margin: 2rem;
text-align: center;
}
#booking h2 {
margin-bottom: 2rem;
}
#booking form {
display: flex;
justify-content: center;
align-items: center;
}
#booking label {
margin-right: 1rem;
}
#booking input, #booking button {
padding: 0.5rem;
font-size: 1rem;
margin-right: 1rem;
}
#booking button {
background-color: #333;
color: #fff;
border: none;
cursor: pointer;
}
footer {
background-color: #333;
color: #fff;
text-align: center;
padding: 1rem;
}
```
JS代码:
```javascript
// 这里可以写一些交互功能的代码,比如表单验证、轮播图等。
```
以上是一个简单的旅游网站的HTML、CSS和JS代码示例,您可以根据自己的需求进行修改和扩展。
阅读全文