制作一个·介绍风景图片的网页的代码
时间: 2024-04-07 22:28:51 浏览: 61
好的,以下是一个简单的介绍风景图片的网页的代码:
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>
<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="gallery">
<div class="gallery-item">
<img src="https://www.example.com/images/grand-canyon.jpg" alt="美国大峡谷">
<h3>美国大峡谷</h3>
</div>
<div class="gallery-item">
<img src="https://www.example.com/images/huangshan.jpg" alt="中国黄山">
<h3>中国黄山</h3>
</div>
<div class="gallery-item">
<img src="https://www.example.com/images/machu-picchu.jpg" alt="秘鲁马丘比丘">
<h3>秘鲁马丘比丘</h3>
</div>
<div class="gallery-item">
<img src="https://www.example.com/images/uluru.jpg" alt="澳大利亚乌鲁鲁">
<h3>澳大利亚乌鲁鲁</h3>
</div>
</div>
</section>
<section>
<h2>推荐图片</h2>
<div class="gallery">
<div class="gallery-item">
<img src="https://www.example.com/images/banff.jpg" alt="加拿大班芙国家公园">
<h3>加拿大班芙国家公园</h3>
</div>
<div class="gallery-item">
<img src="https://www.example.com/images/taj-mahal.jpg" alt="印度泰姬陵">
<h3>印度泰姬陵</h3>
</div>
<div class="gallery-item">
<img src="https://www.example.com/images/mt-fuji.jpg" alt="日本富士山">
<h3>日本富士山</h3>
</div>
<div class="gallery-item">
<img src="https://www.example.com/images/great-barrier-reef.jpg" alt="澳大利亚大堡礁">
<h3>澳大利亚大堡礁</h3>
</div>
</div>
</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;
}
header h1 {
margin: 0;
font-size: 36px;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
}
nav li {
display: inline-block;
margin-right: 20px;
}
nav li:last-child {
margin-right: 0;
}
nav a {
color: #fff;
text-decoration: none;
}
main {
max-width: 960px;
margin: 20px auto;
padding: 0 20px;
}
section {
margin-bottom: 40px;
}
section h2 {
margin-bottom: 20px;
font-size: 24px;
}
.gallery {
display: flex;
flex-wrap: wrap;
}
.gallery-item {
flex-basis: calc(25% - 20px);
margin-right: 20px;
margin-bottom: 20px;
}
.gallery-item:last-child {
margin-right: 0;
}
.gallery-item img {
max-width: 100%;
height: auto;
margin-bottom: 10px;
}
.gallery-item h3 {
margin: 0;
font-size: 16px;
}
```
以上代码仅供参考,实际项目中需要根据具体需求进行修改和完善。
阅读全文