写一个旅游的html和css
时间: 2023-12-28 10:05:13 浏览: 24
下面是一个简单的旅游网站的HTML和CSS示例:
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="#home">首页</a></li>
<li><a href="#destinations">目的地</a></li>
<li><a href="#about">关于我们</a></li>
<li><a href="#contact">联系我们</a></li>
</ul>
</nav>
</header>
<main>
<section id="home">
<h2>欢迎来到旅游网站</h2>
<p>我们提供全球各地的旅游景点和套餐。</p>
<a href="#destinations">浏览目的地</a>
</section>
<section id="destinations">
<h2>热门目的地</h2>
<ul>
<li>
<img src="https://picsum.photos/id/1018/300/200" alt="巴黎">
<h3>巴黎</h3>
<p>浪漫之都巴黎等着你来探索。</p>
<a href="#">查看更多</a>
</li>
<li>
<img src="https://picsum.photos/id/1021/300/200" alt="纽约">
<h3>纽约</h3>
<p>纽约城市的魅力无法抗拒。</p>
<a href="#">查看更多</a>
</li>
<li>
<img src="https://picsum.photos/id/1023/300/200" alt="东京">
<h3>东京</h3>
<p>东京是一个充满活力和文化的城市。</p>
<a href="#">查看更多</a>
</li>
</ul>
</section>
<section id="about">
<h2>关于我们</h2>
<p>我们是一家致力于为旅游爱好者提供最佳旅游体验的公司。</p>
<p>我们的团队由旅游专家和经验丰富的导游组成,为您提供最好的服务。</p>
</section>
<section id="contact">
<h2>联系我们</h2>
<form>
<label for="name">姓名:</label>
<input type="text" id="name" name="name" required>
<label for="email">邮箱:</label>
<input type="email" id="email" name="email" required>
<label for="message">留言:</label>
<textarea id="message" name="message" required></textarea>
<button type="submit">发送</button>
</form>
</section>
</main>
<footer>
<p>© 2021 旅游网站</p>
</footer>
</body>
</html>
```
CSS代码:
```
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
}
nav li {
display: inline-block;
margin-right: 20px;
}
nav a {
color: #fff;
text-decoration: none;
}
main {
max-width: 960px;
margin: 0 auto;
padding: 20px;
}
section {
margin-bottom: 40px;
}
h2 {
font-size: 36px;
margin-bottom: 20px;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
li {
display: inline-block;
width: 300px;
margin-right: 20px;
}
li img {
width: 100%;
height: auto;
}
li h3 {
font-size: 24px;
margin-top: 10px;
margin-bottom: 5px;
}
li p {
font-size: 16px;
margin-bottom: 10px;
}
li a {
display: block;
margin-top: 10px;
}
form label {
display: block;
margin-bottom: 10px;
}
form input,
form textarea {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 4px;
}
form button {
background-color: #333;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
footer {
background-color: #333;
color: #fff;
padding: 20px;
text-align: center;
}
```
这个示例包含一个顶部导航栏、几个主要的网站部分(首页、目的地、关于我们和联系我们),以及页脚。CSS样式定义了网站的颜色、字体和布局。您可以根据需要进行修改和调整。