写一个网页,最上方为标题居中,然后下面是八个有间隔且居中的超链接,下面是是个具有搜索功能的搜索框局中,下面是两行六个图片,一行三个照片,每个图片下面有一行文字,三个图片之间有间隔居中且小,使用 HTML 和 CSS 和 JavaScript 编写
时间: 2024-05-30 22:16:25 浏览: 108
图片和文字居中显示
<!DOCTYPE html>
<html>
<head>
<title>网页标题</title>
<style>
body {
margin: 0;
padding: 0;
}
.header {
background-color: #333;
color: #fff;
text-align: center;
padding: 20px;
font-size: 24px;
font-weight: bold;
}
.nav {
display: flex;
justify-content: center;
align-items: center;
background-color: #eee;
padding: 10px;
}
.nav a {
text-decoration: none;
color: #333;
padding: 10px;
margin: 0 10px;
border: 1px solid #333;
border-radius: 5px;
}
.search {
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.search input[type="text"] {
padding: 10px;
font-size: 18px;
border: 1px solid #333;
border-radius: 5px;
width: 50%;
margin-right: 10px;
}
.search input[type="submit"] {
padding: 10px;
font-size: 18px;
background-color: #333;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
.gallery {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
padding: 20px;
}
.gallery img {
width: 200px;
height: 200px;
object-fit: cover;
margin: 10px;
}
.gallery p {
font-size: 16px;
margin: 0;
padding: 10px;
text-align: center;
}
</style>
</head>
<body>
<header class="header">网页标题</header>
<nav class="nav">
<a href="#">链接1</a>
<a href="#">链接2</a>
<a href="#">链接3</a>
<a href="#">链接4</a>
<a href="#">链接5</a>
<a href="#">链接6</a>
<a href="#">链接7</a>
<a href="#">链接8</a>
</nav>
<section class="search">
<form>
<input type="text" placeholder="请输入搜索内容...">
<input type="submit" value="搜索">
</form>
</section>
<section class="gallery">
<div>
<img src="image1.jpg" alt="图片1">
<p>图片1描述</p>
</div>
<div>
<img src="image2.jpg" alt="图片2">
<p>图片2描述</p>
</div>
<div>
<img src="image3.jpg" alt="图片3">
<p>图片3描述</p>
</div>
<div>
<img src="image4.jpg" alt="图片4">
<p>图片4描述</p>
</div>
<div>
<img src="image5.jpg" alt="图片5">
<p>图片5描述</p>
</div>
<div>
<img src="image6.jpg" alt="图片6">
<p>图片6描述</p>
</div>
</section>
</body>
</html>
阅读全文