麻烦老师帮忙看一下代码的正确性和规范性

麻烦老师帮忙看一下代码的正确性和规范性

具体遇到的问题

报错信息的截图

相关课程内容截图

尝试过的解决思路和结果

老师,我设置了span的margin-top:20px;为什么没有效果呢,请老师解答一下谢谢你。

图片描述

粘贴全部相关代码,切记添加代码注释(请勿截图)

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>aboutPlus4_10</title>
    <link rel="stylesheet" href="css/aboutPlus4_10.css">
</head>
<div class="content">
    <img src="images/b1.jpg" alt="">

    <div class="text">
        <span>Library</span>
        <p class="p1">Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
        <p class="p2">
            Lorem Ipsum has been the industry's standard dummy test ever since the 1500s, when an unknown printer took a galley of type and scrambled to make a type specimen book.
        </p>
        <div class="btn">EXPLORE</div>
    </div>
    <img src="images/b2.jpg" alt="">
    <div class="text">
        <span>Library</span>
        <p class="p1">Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
        <p class="p2">
            Lorem Ipsum has been the industry's standard dummy test ever since the 1500s, when an unknown printer took a galley of type and scrambled to make a type specimen book.
        </p>
        <div class="btn">EXPLORE</div>
    </div>
    <div class="text">
        <span>Library</span>
        <p class="p1">Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
        <p class="p2">
            Lorem Ipsum has been the industry's standard dummy test ever since the 1500s, when an unknown printer took a galley of type and scrambled to make a type specimen book.
        </p>
        <div class="btn">EXPLORE</div>
    </div>
    <img src="images/b3.jpg" alt="">
    <div class="text">
        <span>Library</span>
        <p class="p1">Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p>
        <p class="p2">
            Lorem Ipsum has been the industry's standard dummy test ever since the 1500s, when an unknown printer took a galley of type and scrambled to make a type specimen book.
        </p>
        <div class="btn">EXPLORE</div>
    </div>
    <img class="img4" src="images/b4.jpg" alt="">


</div>

<body>

</body>

</html>
* {
    margin: 0;
    padding: 0;
}

.content {
    width: 100%;
    overflow: hidden;
}

img {
    float: left;
    width: 25%;
    height: 380px;
}

.content .text {
    float: left;
    background: #07cbc9;
    width: 25%;
    height: 380px;
    position: relative;
}

span {
    font-size: 24px;
    margin-top: 20px;
    margin-left: 20px;
}

.p1 {
    font-size: 16px;
    margin-top: 30px;
    margin-bottom: 20px;
    margin-left: 20px;
}

.p2 {
    font-size: 14px;
    color: gray;
    margin-left: 20px;
    margin-bottom: 30px;
}

.btn {
    width: 138px;
    height: 40px;
    background: black;
    color: white;
    text-align: center;
    line-height: 40px;
    margin: 0 auto;
}

正在回答

登陆购买课程后可参与讨论,去登陆

1回答

同学你好,针对同学的问题进行回复:因为span标签是行内元素,给行内元素设置margin-top、margin-bottom属性设置都是无效的,所以margin-top:20px;不生效。建议把span标签换成p标签,修改如下:

http://img1.sycdn.imooc.com//climg/5fa90f8f09ae439812110222.jpg

http://img1.sycdn.imooc.com//climg/5fa90f9509c9911303720144.jpg

效果优化:

给p标签设置字体颜色为白色,这样页面效果更接近效果图,参考下图:

http://img1.sycdn.imooc.com//climg/5fa9146c0926763603510162.jpg

效果:

http://img1.sycdn.imooc.com//climg/5fa9147a090d0e8318940331.jpg

祝学习愉快!

  • 日拱一卒_ 提问者 #1
    好的,谢谢老师的解答,已经订正了
    2020-11-10 08:20:25
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师