请用html5和css写一个旅游宣传页
时间: 2024-04-02 07:32:56 浏览: 12
好的,我可以帮您完成这个任务。以下是一个简单的示例:
HTML5代码:
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>旅游宣传页</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>欢迎来到旅游宣传页</h1>
<nav>
<ul>
<li><a href="#about">关于我们</a></li>
<li><a href="#destinations">目的地</a></li>
<li><a href="#contact">联系我们</a></li>
</ul>
</nav>
</header>
<main>
<section id="hero">
<h2>发现你的梦想之旅</h2>
<a href="#destinations">浏览目的地</a>
</section>
<section id="about">
<h2>关于我们</h2>
<p>我们是一个专业的旅游公司,致力于为客户提供最好的旅游体验。</p>
</section>
<section id="destinations">
<h2>目的地</h2>
<ul>
<li>
<img src="https://via.placeholder.com/150" alt="目的地1">
<h3>目的地1</h3>
<p>在这里,您可以享受美丽的风景和丰富多彩的文化。</p>
</li>
<li>
<img src="https://via.placeholder.com/150" alt="目的地2">
<h3>目的地2</h3>
<p>这里有美味的食物和独特的建筑风格。</p>
</li>
<li>
<img src="https://via.placeholder.com/150" alt="目的地3">
<h3>目的地3</h3>
<<p>这里有令人惊叹的自然景观和刺激的户外活动。</p>
</li>
</ul>
</section>
<section id="contact">
<h2>联系我们</h2>
<form action="submit-form.php" method="post">
<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 旅游宣传页. All Rights Reserved.</p>
</footer>
</body>
</html>
```
CSS代码:
```
* {
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
margin: 0;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
nav li {
margin: 0 10px;
}
nav a {
color: #fff;
text-decoration: none;
font-weight: bold;
}
main {
max-width: 800px;
margin: 0 auto;
}
section {
padding: 50px 0;
text-align: center;
}
section h2 {
font-size: 36px;
margin-bottom: 20px;
}
section p {
font-size: 18px;
line-height: 1.5;
margin-bottom: 30px;
}
section ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
justify-content: space-between;
}
section li {
flex-basis: 30%;
border: 1px solid #ccc;
padding: 20px;
}
section li img {
display: block;
margin: 0 auto 10px;
}
section li h3 {
margin-bottom: 10px;
}
section li p {
font-size: 14px;
line-height: 1.5;
}
#hero {
background-image: url('https://via.placeholder.com/1200x400');
background-size: cover;
background-position: center;
color: #fff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 400px;
}
#hero h2 {
font-size: 48px;
margin-bottom: 20px;
}
#hero a {
background-color: #fff;
color: #333;
padding: 10px 20px;
font-size: 18px;
text-decoration: none;
border-radius: 5px;
}
#hero a:hover {
background-color: #333;
color: #fff;
}
form label {
display: block;
font-size: 18px;
margin-bottom: 10px;
}
form input,
form textarea {
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
width: 100%;
margin-bottom: 20px;
}
form button {
background-color: #333;
color: #fff;
padding: 10px 20px;
font-size: 18px;
text-decoration: none;
border-radius: 5px;
border: none;
}
form button:hover {
background-color: #fff;
color: #333;
cursor: pointer;
}
```
您可以将上述代码保存为HTML和CSS文件,然后在浏览器中打开HTML文件,即可查看旅游宣传页的效果。