用html+css做一个简单的旅游网站
时间: 2023-12-26 19:05:29 浏览: 31
好的,我可以给你提供一个简单的示例,你可以根据自己的需求进行修改和完善。
首先,需要创建一个 HTML 文件,然后在文件中编写基本的网页结构和内容。下面是一个简单的示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>旅游网站</title>
<link rel="stylesheet" type="text/css" 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>
<h2>热门目的地</h2>
<div class="destination">
<img src="destination1.jpg" alt="destination1">
<h3>目的地1</h3>
<p>描述目的地1的一些信息...</p>
<button>查看详情</button>
</div>
<div class="destination">
<img src="destination2.jpg" alt="destination2">
<h3>目的地2</h3>
<p>描述目的地2的一些信息...</p>
<button>查看详情</button>
</div>
<div class="destination">
<img src="destination3.jpg" alt="destination3">
<h3>目的地3</h3>
<p>描述目的地3的一些信息...</p>
<button>查看详情</button>
</div>
</section>
<section>
<h2>推荐行程</h2>
<div class="trip">
<img src="trip1.jpg" alt="trip1">
<h3>行程1</h3>
<p>描述行程1的一些信息...</p>
<button>查看详情</button>
</div>
<div class="trip">
<img src="trip2.jpg" alt="trip2">
<h3>行程2</h3>
<p>描述行程2的一些信息...</p>
<button>查看详情</button>
</div>
<div class="trip">
<img src="trip3.jpg" alt="trip3">
<h3>行程3</h3>
<p>描述行程3的一些信息...</p>
<button>查看详情</button>
</div>
</section>
</main>
<footer>
<p>版权所有 © 2021 旅游网站</p>
</footer>
</body>
</html>
```
在上面的示例中,我们创建了一个简单的旅游网站,包括一个标题和导航菜单,以及两个主要内容区域(热门目的地和推荐行程),还有一个页脚。
接下来,我们需要创建一个样式表文件 `style.css`,来为网站添加样式。下面是一个简单的示例:
```css
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #fff;
padding: 20px;
}
h1 {
margin: 0;
}
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: 1000px;
margin: 0 auto;
padding: 20px;
}
section {
margin-bottom: 40px;
}
h2 {
margin-top: 0;
}
.destination, .trip {
display: inline-block;
vertical-align: top;
margin-right: 20px;
}
.destination img, .trip img {
max-width: 300px;
}
.destination h3, .trip h3 {
margin-top: 10px;
margin-bottom: 5px;
}
.destination p, .trip p {
margin-top: 0;
}
button {
background-color: #333;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #555;
}
```
在上面的示例中,我们定义了一些基本样式,如字体、颜色、间距等。我们还为目的地和行程添加了样式,如图片大小、标题样式等。
最后,将图片文件 `destination1.jpg`、`destination2.jpg`、`destination3.jpg`、`trip1.jpg`、`trip2.jpg`、`trip3.jpg` 放置在与 HTML 文件和样式表文件相同的目录下。
现在,你可以在浏览器中打开 HTML 文件,查看你的旅游网站的效果了。