请老师检查下代码,是否还有哪里需要优化的?
来源:2-17 自由编程
不厌_
2021-05-25 10:00:20
CSS部分代码:
相关代码:
* {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
}
ul,ol {
list-style: none;
}
body {
font: normal 14px/25px "微软雅黑";
}
/* header区域 */
header {
width: 100%;
height: 80px;
background-color: #07cbc9;
}
header .header-top {
width: 1200px;
height: 80px;
margin: 0px auto;
}
header .header-top .logo {
width: 260px;
height: 48px;
float: left;
padding-top: 16px;
padding-bottom: 16px;
}
header .header-top .logo img {
width: 260px;
height: 48px;
}
header .header-top .main-nav {
height: 80px;
float: right;
}
header .header-top .main-nav ul {
height: 80px;
}
header .header-top .main-nav ul li {
width: 100px;
height: 80px;
float: left;
margin-right: 20px;
text-align: center;
line-height: 80px;
}
header .header-top .main-nav ul li a{
display: block;
width: 100px;
height: 80px;
color: white;
font-size: 16px;
}
header .header-top .main-nav ul li a:hover {
background-color: orange;
}
/* banner区域 */
.banner {
width: 100%;
height: 800px;
position: relative;
}
.banner .banner-pictures{
width: 100%;
height: 800px;
}
.banner .banner-pictures img{
width: 100%;
height: 800px;
}
/* 遮罩层 */
.banner .banner-shade {
position: absolute;
width: 100%;
height: 800px;
top: 0px;
left: 0px;
background-color:rgba(0, 0, 0, 0.5);
}
/* banner表单 */
.banner .banner-form {
width: 504px;
/* 实现水平居中 */
position: absolute;
left: 50%;
margin-left: -252px;
top: 100px;
overflow: hidden;
/* 输入框居中 */
text-align: center;
}
.banner .banner-form input,textarea {
background: none;
color: #808080;
/* 鼠标点击时去掉边框 */
outline: none;
}
.banner .banner-form .input-box {
width: 500px;
height: 36px;
border: 2px solid #808080;
margin-bottom: 30px;
}
.banner .banner-form .comment {
width: 500px;
height: 106px;
border: 2px solid #808080;
margin-bottom: 30px;
}
.banner .banner-form .send-message {
width: 196px;
height: 36px;
border: 2px solid #808080;
}
/* about区域 */
.content .about{
width: 1201px;
margin: 0 auto;
margin-top: 30px;
overflow: hidden;
}
/* <!-- about区域的标题和简短描述(跟下面的gallery简短标题与描述样式一致) --> */
.content .about .about-title-short-description {
width: 1201;
}
.content .about .about-title-short-description h2,.content .gallery .gallery-title-short-description h2 {
text-align: center;
font-size: 32px;
}
.content .about .about-title-short-description .divider,.content .gallery .gallery-title-short-description .divider {
width: 60px;
height: 3px;
background-color: #07cbc9;
margin: 10px auto;
}
.content .about .about-title-short-description p,.content .gallery .gallery-title-short-description p {
font-size: 14px;
color: gray;
text-align: center;
}
/* about区域的详细描述 */
.content .about .about-detailed-description {
width: 1201px;
height: 434px;
padding-top: 30px;
position: relative;
}
/* 左部分区域 */
.content .about .about-detailed-description .about-left {
float: left;
}
.content .about .about-detailed-description .about-left h2{
margin-bottom: 20px;
margin-right: 158px;
}
.content .about .about-detailed-description .about-left .about-left-description {
width: 300px;
padding: 20px;
border: 1px solid gray;
font-size: 18px;
position: absolute;
top: 50%;
left: 0;
margin-top: -100px;
background:rgba(255, 255, 255, .5)
}
.content .about .about-detailed-description .about-left .about-left-description a{
display: block;
width: 140px;
height: 40px;
background-color: black;
color: white;
line-height: 40px;
text-align: center;
margin-top: 30px;
}
/* 中部图片区域 */
.content .about .about-detailed-description .about-among{
width: 650px;
height: 435px;
float: left;
}
.content .about .about-detailed-description .about-among img {
width: 650px;
height: 435px;
}
/* 右部分区域 */
.content .about .about-detailed-description .about-right {
width: 260px;
float: right;
}
.content .about .about-detailed-description .about-right .about-right-box {
width: 178px;
padding: 40px;
border: 1px solid #07cbc9;
text-align: center;
}
.content .about .about-detailed-description .about-right .about-right-box p{
font-size: 28px;
font-weight: bold;
}
.content .about .about-detailed-description .about-right .about-right-box .divider {
width: 60px;
height: 3px;
background-color: #07cbc9;
margin: 10px auto;
}
.content .about .about-detailed-description .about-right .top {
margin-bottom: 30px;
}
/* 图文混排区域 */
.content .pictures-and-text {
width: 100%;
height: 760px;
margin-top: 20px;
}
/* 四张图片四块文字实现两排四列效果 */
.content .pictures-and-text .picture img {
display: block;
width: 25%;
height: 380px;
float: left;
}
.content .pictures-and-text .text {
width: 25%;
height: 380px;
float: left;
background-color: #07cbc9;
position: relative;
}
/* 第一排三角形 */
.content .pictures-and-text .first-triangle::before {
content: " ";
width: 0;
height: 0;
border: 20px solid transparent;
border-right-color: #07cbc9;
position: absolute;
top: 170px;
left: -40px;
}
/* 第二排三角形 */
.content .pictures-and-text .second-triangle::before {
content: " ";
width: 0;
height: 0;
border: 20px solid transparent;
border-left-color: #07cbc9;
position: absolute;
bottom: 170px;
right: -40px;
}
.content .pictures-and-text .text h3 {
padding: 20px 0px 30px 20px;
font-size: 24px;
color: white;
}
.content .pictures-and-text .text p:nth-child(2) {
font-size: 16px;
padding: 0px 20px 20px 20px;
}
.content .pictures-and-text .text p:nth-child(3) {
font-size: 14px;
color: gray;
padding: 0px 20px;
}
.content .pictures-and-text .text a.button {
display: block;
background-color: black;
color: white;
line-height: 40px;
text-align: center;
width: 138px;
height: 40px;
margin: 0 auto;
margin-top: 30px;
}
/* gallery区域 */
.content .gallery {
width: 1200px;
margin: 0 auto;
margin-top: 30px;
}
/* 标题与简短描述样式跟上面ABOUT区域一致 */
.content .gallery .gallery-title-short-description {
width: 1200px;
margin: 0 auto;
}
/* gallery的详细区域 */
.content .gallery .detailed-information {
width: 1160px;
height: 613px;
padding: 20px;
}
.content .gallery .detailed-information div.box {
width: 360px;
height: 290px;
float: left;
margin-right: 40px;
margin-bottom: 20px;
overflow: hidden;
}
.content .gallery .detailed-information div:nth-child(3),.content .gallery .detailed-information div:nth-child(6){
margin-right: 0px;
}
.content .gallery .detailed-information div dl dt img{
display: block;
width: 360px;
height: 240px;
}
.content .gallery .detailed-information div dl dd {
width: 360;
height: 50px;
background-color: black;
color: white;
line-height: 50px;
padding-left:20px;
}
/* footer区域 */
footer {
margin-top: 10px;
width: 100%;
height: 80px;
background-color: #07cbc9;
text-align: center;
line-height: 80px;
}
HTML部分代码:
相关代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="Keywoeds" content="#">
<meta name="Description" content="#">
<title>Career-Builder</title>
<link rel="stylesheet" href="css/css.css">
</head>
<body>
<!-- 网页头部 -->
<header>
<div class="header-top">
<!-- 网页的LOGO -->
<div class="logo">
<img src="images/logo.png" alt="">
</div>
<!-- 网页的导航 -->
<nav class="main-nav">
<ul>
<li><a href="">HOME</a></li>
<li><a href="">ABOUT</a></li>
<li><a href="">GALLERY</a></li>
<li><a href="">FACULTY</a></li>
<li><a href="">EVENTS</a></li>
<li><a href="">CONTACT</a></li>
</ul>
</nav>
</div>
</header>
<!-- 网页的横幅 -->
<section class="banner">
<!-- 网页横幅的图片 -->
<div class="banner-pictures">
<img src="images/banner3.jpg" alt="">
</div>
<!-- 网页横幅的遮罩层 -->
<div class="banner-shade">
</div>
<!-- 网页横幅的表单 -->
<div class="banner-form">
<form action="" method="POST">
<p>
<input class="input-box" type="text" placeholder="your Name">
</p>
<p>
<input class="input-box" type="text" placeholder="your Phone">
</p>
<p>
<input class="input-box" type="email" placeholder="your Email">
</p>
<p>
<textarea class="comment" cols="30" rows="10" placeholder="Write Your Comment Here"></textarea>
</p>
<p>
<input class="send-message" type="submit" value="SEND MESSAGE">
</p>
</form>
</div>
</section>
<!-- 网页的内容区域 -->
<section class="content">
<!-- 网页的标题和描述区域 -->
<div class="about">
<!-- 标题和简短描述 -->
<div class="about-title-short-description">
<!-- 标题 -->
<h2>ABOUT</h2>
<!-- 简短描述 -->
<div class="divider"></div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting <br> industry. Lorem Ipsum has been the industry's standard dummy <br> text ever since the 1500s.</p>
</div>
<!-- 详细描述 -->
<div class="about-detailed-description">
<!-- 左部分 -->
<div class="about-left">
<!-- 左边部分标题 -->
<h2>A WORD <br> ABOUT US</h2>
<!-- 左边部分内容 -->
<div class="about-left-description">
<P>Praesent dignissim viverra est, sed bibendum ligula congue non. Sed ac nisl et felis gravida commodo? Suspendisse eget ullamcorper ipsum. Suspendisse diam amet.</P>
<a href="">EXPLORE</a>
</div>
</div>
<!-- 中部 -->
<div class="about-among">
<img src="images/bb3.jpg" alt="">
</div>
<!-- 右部分 -->
<div class="about-right">
<!-- 右边上部分内容 -->
<div class="about-right-box top">
<p>70000</p>
<div class="divider"></div>
<div>Students</div>
</div>
<!-- 右边下半部分内容 -->
<div class="about-right-box bottom">
<p>600</p>
<div class="divider"></div>
<div>Faculty</div>
</div>
</div>
</div>
</div>
<!-- 网页的图文混排区域 -->
<div class="pictures-and-text">
<!-- 图片1 -->
<div class="picture">
<img src="images/b1.jpg" alt="">
</div>
<!-- 文字2 -->
<div class="text first-triangle">
<h3>Library</h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<a href="" class="button">EXPLORE</a>
</div>
<!-- 图片3 -->
<div class="picture">
<img src="images/b2.jpg" alt="">
</div>
<!-- 文字4 -->
<div class="text first-triangle">
<h3>Library</h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<a href="" class="button">EXPLORE</a>
</div>
<!-- 文字5 -->
<div class="text second-triangle">
<h3>Library</h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<a href="" class="button">EXPLORE</a>
</div>
<!-- 图片6 -->
<div class="picture">
<img src="images/b3.jpg" alt="">
</div>
<!-- 文字7 -->
<div class="text second-triangle">
<h3>Library</h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<a href="" class="button">EXPLORE</a>
</div>
<!-- 图片8 -->
<div class="picture">
<img src="images/b4.jpg" alt="">
</div>
</div>
<!-- 网页的展示区 -->
<div class="gallery">
<!-- 标题和简短描述 -->
<div class="gallery-title-short-description">
<!-- GALLERY标题 -->
<h2>GALLERY</h2>
<!-- 简短描述 -->
<div class="divider"></div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting <br> industry. Lorem Ipsum has been the industry's standard dummy <br> text ever since the 1500s.</p>
</div>
<!-- 详细信息区 -->
<div class="detailed-information">
<!-- 第一块内容 -->
<div class="detailed-information-one box">
<dl>
<dt><img src="images/03-01.jpg" alt=""></dt>
<dd>Science Lab</dd>
</dl>
</div>
<!-- 第二块内容 -->
<div class="detailed-information-two box">
<dl>
<dt><img src="images/03-02.jpg" alt=""></dt>
<dd>Indoor Stadium</dd>
</dl>
</div>
<!-- 第三块内容 -->
<div class="detailed-information-three box">
<dl>
<dt><img src="images/03-03.jpg" alt=""></dt>
<dd>Transportation</dd>
</dl>
</div>
<!-- 第四块内容 -->
<div class="detailed-information-four box">
<dl>
<dt><img src="images/03-04.jpg" alt=""></dt>
<dd>Kids Room</dd>
</dl>
</div>
<!-- 第五块内容 -->
<div class="detailed-information-five box">
<dl>
<dt><img src="images/03-05.jpg" alt=""></dt>
<dd>Meditation Classes</dd>
</dl>
</div>
<!-- 第六块内容 -->
<div class="detailed-information-five box">
<dl>
<dt><img src="images/03-06.jpg" alt=""></dt>
<dd>Kids Play Ground</dd>
</dl>
</div>
</div>
</div>
</section>
<!-- 网页的页脚 -->
<footer>
<p>©2016 imooc.com 京ICP备13046642号</p>
</footer>
</body>
</html>
1回答
同学你好,代码是对的,可做如下优化:
两排四列图文混排,图片和文字所在的div的样式可以设置成一样的,如下这样调整,样式更规范:
祝学习愉快!
相似问题