老师请帮忙检查一下代码的正确性和规范性,谢谢你。
来源:4-8 自由编程
日拱一卒_
2020-11-09 15:17:12
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>about4_8</title>
<link rel="stylesheet" href="css/about4_8.css">
</head>
<body>
<div class="header">
<p class="header-p">ABOUT</p>
<div class="outline"></div>
<span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy test ever since the 1500s.</span>
</div>
<div class="content">
<img src="images/bb3.jpg" alt="">
<div class="leftBox">
<p class="leftBox-p">
A WORD
<br> ABOUT US
</p>
<div class="leftBox-text">
<span>Praesent dignissim viverra est, sed bibendum ligula congue non.Sed ac nisl et felis gravida commodo? Suspendisse eget ullamcorper ipsum. Suspendisse diam amet.
</span>
<button>EXPLORE</button>
</div>
</div>
<div class="rightBox">
<div class="students">
<p>70000</p>
<div class="outline"></div>
<span>Students</span>
</div>
<div class="faculty">
<p>600</p>
<div class="outline"></div>
<span>Faculty</span>
</div>
</div>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
}
.header .header-p {
text-align: center;
margin-top: 30px;
font-size: 32px;
font-weight: bold;
}
.outline {
width: 60px;
height: 3px;
background: #07cbc9;
margin: 10px auto;
}
.header span {
display: block;
text-align: center;
color: gray;
font-size: 14px;
}
.content {
width: 1200px;
height: 464px;
margin: 0 auto;
position: relative;
}
.content img {
width: 650px;
height: 435px;
position: absolute;
left: 50%;
margin-left: -325px;
margin-top: 30px;
}
.content .leftBox {
float: left;
position: absolute;
}
.content .leftBox .leftBox-p {
text-align: left;
font-size: 32px;
font-weight: bold;
margin: 30px 0;
}
.content .leftBox .leftBox-text {
float: left;
width: 300px;
padding: 20px;
font-size: 18px;
border: 1px solid gray;
background: rgba(255, 255, 255, .5);
}
.content .leftBox .leftBox-text span {
display: block;
width: 300px;
margin: 20px;
}
.content .leftBox .leftBox-text button {
width: 140px;
height: 40px;
margin-bottom: 20px;
margin-left: 20px;
background: black;
color: white;
}
.content .rightBox {
position: absolute;
right: 0;
margin-top: 30px;
}
.content .rightBox .students {
width: 260px;
padding: 40px 0;
border: 1px solid #07cbc9;
margin-bottom: 30px;
}
.content .rightBox .faculty {
width: 260px;
padding: 40px 0;
border: 1px solid #07cbc9;
margin-bottom: 30px;
}
.content .rightBox p {
font-size: 28px;
font-weight: bold;
text-align: center;
}
.rightBox span {
display: block;
font-size: 18px;
text-align: center;
}
1回答
同学你好,代码效果实现了哦,不过效果还可以进行优化,建议如下:
1、给类名叫header的容器设置固定的宽度,通过margin:0 auto;实现水平居中的效果,参考下图:
效果:
2、类名叫content的区域的效果实现了,但是中间的布局实现的有些复杂,可以参考老师的建议把布局修改一下:
(1)设置一个蓝色的大div盒子,使用margin:0 auto;属性设置蓝色盒子居中,建议:设置蓝色盒子宽度为1000px左右。
(2)里面3个小的绿色div,按照从左到右布局,首先是左侧小标题,其次是中间的图片,然后为右侧的两个小区域。可以设置浮动使其显示在一行。用margin调整三个盒子的间距
(3)最后再设置一个粉色div容纳遮罩的这部分,并使用绝对定位,要相对于上面说到的蓝色大div。
(4)遮罩层可以使用background:rgba(255,255,255,0.7);属性设置背景透明度实现效果。
祝学习愉快!
相似问题