写出相应的HTML文件和css样式文件,要求如下:页面布局自上而下有六个盒子,,第一个盒子背景图片是img1,在该背景图片上左上角是一个logo图片,背景图片上有一栏是页面导航栏有四个选项,第二个盒子右面是一张背景图片,左边有一段文字,文字下方是一个按钮,第三个盒子,背景图片是img3,背景图片上是一段文字,最右面一个按钮,第四个盒子上面有一段文字,中间左右布局两个小盒子,小盒子之间间隙10px,第五个盒子,中间有个小盒子,小盒子左右两个圆形按钮,小盒子里图片img居中显示,第六个盒子背景图片是img6,最下面有一根直线,直线下是footer内容是浙江理工大学
时间: 2024-03-03 07:50:38 浏览: 68
HTML文件:
```html
<!DOCTYPE html>
<html>
<head>
<title>Box Layout</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="box" id="box1">
<div class="logo">
<img src="logo.png">
</div>
<div class="nav">
<ul>
<li><a href="#">Option 1</a></li>
<li><a href="#">Option 2</a></li>
<li><a href="#">Option 3</a></li>
<li><a href="#">Option 4</a></li>
</ul>
</div>
</div>
<div class="box" id="box2">
<div class="text">
<h2>Box 2 Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tincidunt sapien ut urna iaculis ultrices. Nulla facilisi. Fusce aliquet leo vitae nulla bibendum, non bibendum velit tristique. Cras ac nisl vel lorem pellentesque bibendum. Suspendisse non risus vel nibh porttitor interdum. </p>
</div>
<div class="btn">
<button>Click Here</button>
</div>
</div>
<div class="box" id="box3">
<div class="text">
<h2>Box 3 Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tincidunt sapien ut urna iaculis ultrices. Nulla facilisi. Fusce aliquet leo vitae nulla bibendum, non bibendum velit tristique. Cras ac nisl vel lorem pellentesque bibendum. Suspendisse non risus vel nibh porttitor interdum. </p>
</div>
<div class="btn">
<button>Click Here</button>
</div>
</div>
<div class="box" id="box4">
<div class="text">
<h2>Box 4 Title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tincidunt sapien ut urna iaculis ultrices. Nulla facilisi. Fusce aliquet leo vitae nulla bibendum, non bibendum velit tristique. Cras ac nisl vel lorem pellentesque bibendum. Suspendisse non risus vel nibh porttitor interdum. </p>
</div>
<div class="smallbox">
<div class="left"></div>
<div class="right"></div>
</div>
</div>
<div class="box" id="box5">
<div class="smallbox">
<div class="left">
<button></button>
</div>
<div class="center">
<img src="img.png">
</div>
<div class="right">
<button></button>
</div>
</div>
</div>
<div class="box" id="box6">
<div class="footer">
<p>浙江理工大学</p>
</div>
</div>
</body>
</html>
```
CSS文件:
```css
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
.box {
width: 100%;
height: 300px;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
position: relative;
}
#box1 {
background-image: url(img1.jpg);
}
#box2 {
background-image: url(img2.jpg);
}
#box3 {
background-image: url(img3.jpg);
}
#box4 {
background-color: #f5f5f5;
}
#box5 {
background-color: #fff;
}
#box6 {
background-image: url(img6.jpg);
}
.logo {
position: absolute;
top: 20px;
left: 20px;
}
.nav {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.nav ul {
list-style: none;
display: flex;
margin: 0;
padding: 0;
}
.nav li {
margin: 0 10px;
}
.nav a {
color: #fff;
text-decoration: none;
font-size: 18px;
}
.text {
width: 50%;
margin: 0 auto;
padding: 50px 0;
}
.text h2 {
font-size: 36px;
margin-bottom: 20px;
}
.text p {
font-size: 18px;
line-height: 1.5;
}
.btn {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
}
.btn button {
padding: 10px 20px;
background-color: #fff;
border: none;
font-size: 18px;
color: #333;
cursor: pointer;
}
.smallbox {
display: flex;
justify-content: center;
align-items: center;
}
.smallbox .left, .smallbox .right {
width: 50%;
height: 100px;
background-color: #ccc;
margin: 0 5px;
}
.smallbox .center {
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #ccc;
display: flex;
justify-content: center;
align-items: center;
}
.smallbox .center img {
max-width: 100%;
max-height: 100%;
}
.footer {
background-color: #333;
color: #fff;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
}
.footer p {
font-size: 24px;
margin: 0;
}
```
阅读全文