老师,看看这个对不喽~后附一个问题
来源:4-8 自由编程
慕仰5120631
2021-03-31 15:04:06
<div class="about">
<!-- aoubtUp -->
<div class="aboutUp">
<h2>ABOUT</h2>
<!-- <p>分割线</p> -->
<div class="line"></div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting</p>
<p>industry. Lorem Ipsum has been the industry's standard dummy</p>
<p>text ever since the 1500s.</p>
</div>
<!-- aoubtDown -->
<div class="aboutDown">
<div class="leftWord">
<h2>A WORD</h2>
<h2>ABOUT US</h2>
<div class="para">
<p class="p1">Praesent dignissim viverra est, sed bibendum ligula congue non. Sed ac nisl et felis gravida commodo?
Suspendisse eget ullamcorper ipsum. Suspendisse diam amet.</p>
<p class="p2">EXPLORE</p>
</div>
</div>
<img class="img" src="./images/bb3.jpg" alt="">
<div class="rightWord">
<div class="box1">
<p>70000</p>
<div class="line"></div>
<p>student</p>
</div>
<div class="box2">
<p>600</p>
<div class="line"></div>
<p>Faculty</p>
</div>
</div>
</div>
</div>
.about .aboutUp h2{
font-size: 32px;
text-align: center;
padding-top: 30px;
}
.about .line{
width: 60px;
height: 3px;
background: #07cbc9;
margin: 10px auto;
}
.about .aboutUp p{
text-align: center;
color: gray;
font-size: 14px;
}
.about .aboutDown{
width: 1200px;
height: 465px;
/* background: gray; */
margin:0 auto ;
position: relative;
}
.about .aboutDown img.img{
width: 650px;
height: 435px;
position: absolute;
top: 30px;
left: 50%;
margin-left: -325px;
z-index: 999;
}
.about .aboutDown .leftWord{
float: left;
}
.about .aboutDown .leftWord .para{
width: 300px;
padding:20px;
background: rgba(255,255, 255, 0.5);
position: relative;
z-index: 9999;
text-align: left;
font-size: 18px ;
border: 1px solid gray;
}
.about .aboutDown .leftWord h2{
font-size: 28px;
margin-bottom: 15px;
}
.about .aboutDown .rightWord{
float: right;
}
.about .aboutDown .rightWord .box1,.box2{
width: 260px;
margin-bottom: 30px;
padding: 40px 0;
}
.about .aboutDown .rightWord .box1 p:first-child,
.about .aboutDown .rightWord .box2 p:first-child{
font-size: 28px;
font-weight: bold;
text-align: center;
}
.about .aboutDown .rightWord .box1 p:last-child,
.about .aboutDown .rightWord .box2 p:last-child{
font-size: 18px;
text-align: center;
}
老师,代码有什么地方需要改进的优化的吗~
另外有一个问题:
我的.leftWord和.rightWord两个盒子,都没有设置宽度。为什么它没有默认是100%宽呢,实际上它的宽度是被内容给撑开的好像。麻烦老师解答
1回答
同学你好,页面效果实现基本不错,不过存在一些小题,如图

建议参考如下修改
关于同学的问题解答:.leftWord和.rightWord是两个div盒子,div本身是块级元素(block),未设定宽度的话,它的宽度默认就是100%的,当把它浮动(即设置float)后它就变成行内块级元素(inline-block)了,其宽度和高度由内容撑开。祝学习 愉快!
相似问题
回答 1
回答 1
回答 1
回答 1
回答 1