写出对应的html和css文件,一共有五个盒子,第一个盒子上面是一个页面导航栏,导航栏有四个选项,当鼠标在某个选项时,字由黑色变为黄底白字,点击四个选项分别跳转到1-4个盒子,导航栏下是一张居中的图片,第二个盒子有一个居中的标题,里面有一个小盒子居中,黄色背景,小盒子左边是图片,右边是标题加文字加按钮,当鼠标在按钮悬停时变为红色,同时鼠标的形状变为手,第三个盒子有一个靠左的标题,里面有一个小盒子,小盒子有外边框,小盒子左侧是一张图片,右侧上方是标题,下方是文字,,小盒子下面是两个方形按钮,点击按钮分别切换上一张和下一张,第四个盒子,上方标题居中,然后有三个小盒子水平放置,每个小盒子布局从上到下,是图片、小标题、大标题、正文、按钮,按钮在鼠标悬停时变色,第五个盒子是页脚区,将文字均分三份,水平放置
时间: 2024-03-11 22:49:39 浏览: 90
HTML文件:
```
<!DOCTYPE html>
<html>
<head>
<title>My Webpage</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<nav>
<ul>
<li><a href="#section1">Section 1</a></li>
<li><a href="#section2">Section 2</a></li>
<li><a href="#section3">Section 3</a></li>
<li><a href="#section4">Section 4</a></li>
</ul>
</nav>
<section id="section1">
<img src="image.jpg">
</section>
<section id="section2">
<h1>Title</h1>
<div class="box1">
<img src="image.jpg">
<div class="box1-text">
<h2>Title</h2>
<p>Text</p>
<button>Button</button>
</div>
</div>
</section>
<section id="section3">
<h1 class="left">Title</h1>
<div class="box2">
<img src="image.jpg">
<div class="box2-text">
<h2>Title</h2>
<p>Text</p>
<div class="box2-buttons">
<button>Previous</button>
<button>Next</button>
</div>
</div>
</div>
</section>
<section id="section4">
<h1>Title</h1>
<div class="box3">
<div class="box3-item">
<img src="image.jpg">
<h3>Subtitle</h3>
<h2>Title</h2>
<p>Text</p>
<button>Button</button>
</div>
<div class="box3-item">
<img src="image.jpg">
<h3>Subtitle</h3>
<h2>Title</h2>
<p>Text</p>
<button>Button</button>
</div>
<div class="box3-item">
<img src="image.jpg">
<h3>Subtitle</h3>
<h2>Title</h2>
<p>Text</p>
<button>Button</button>
</div>
</div>
</section>
<footer>
<div class="footer-item">
<p>Text 1</p>
</div>
<div class="footer-item">
<p>Text 2</p>
</div>
<div class="footer-item">
<p>Text 3</p>
</div>
</footer>
</body>
</html>
```
CSS文件:
```
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
nav {
background-color: #333;
color: #fff;
padding: 10px 0;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
text-align: center;
}
nav li {
display: inline-block;
margin: 0 10px;
}
nav a {
color: #fff;
text-decoration: none;
padding: 5px 10px;
border-radius: 5px;
transition: all 0.3s ease;
}
nav a:hover {
background-color: #ffc107;
color: #333;
}
section {
padding: 50px 0;
text-align: center;
}
section img {
max-width: 100%;
height: auto;
}
h1 {
font-size: 36px;
margin-bottom: 30px;
}
.box1 {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
background-color: #ffc107;
padding: 30px;
}
.box1 img {
max-width: 100%;
height: auto;
flex-basis: 40%;
margin-right: 30px;
}
.box1-text {
flex-basis: 60%;
text-align: left;
}
.box1-text h2 {
font-size: 24px;
margin-bottom: 15px;
}
.box1-text p {
font-size: 16px;
margin-bottom: 15px;
}
.box1-text button {
background-color: #ffc107;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
}
.box1-text button:hover {
background-color: #e60000;
}
.left {
text-align: left;
}
.box2 {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
border: 2px solid #333;
padding: 30px;
}
.box2 img {
max-width: 100%;
height: auto;
flex-basis: 40%;
margin-right: 30px;
}
.box2-text {
flex-basis: 60%;
text-align: left;
}
.box2-text h2 {
font-size: 24px;
margin-bottom: 15px;
}
.box2-text p {
font-size: 16px;
margin-bottom: 15px;
}
.box2-buttons {
display: flex;
justify-content: center;
align-items: center;
margin-top: 30px;
}
.box2-buttons button {
background-color: #ffc107;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
}
.box2-buttons button:hover {
background-color: #e60000;
}
.box3 {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
.box3-item {
background-color: #ffc107;
padding: 30px;
margin: 30px;
flex-basis: calc(33.33% - 60px);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.box3-item img {
max-width: 100%;
height: auto;
margin-bottom: 15px;
}
.box3-item h3 {
font-size: 18px;
margin-bottom: 15px;
}
.box3-item h2 {
font-size: 24px;
margin-bottom: 15px;
}
.box3-item p {
font-size: 16px;
margin-bottom: 15px;
}
.box3-item button {
background-color: #ffc107;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
}
.box3-item button:hover {
background-color: #e60000;
}
footer {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #333;
color: #fff;
padding: 20px;
}
.footer-item {
flex-basis: calc(33.33% - 20px);
text-align: center;
}
.footer-item p {
font-size: 16px;
margin: 0;
}
```
阅读全文