请老师检查代码

来源:4-10 自由编程

lascride

2021-04-26 22:25:12

请老师检查一下代码哪里还需要改进, 感觉自己的类名是不是用的太多了,导致代码过于臃肿

 <!-- 图文混排区域 -->
    <section class="img-text">
        <div class="img">
            <img src="./images/b1.jpg" alt="">
        </div>
        <div class="text">
            <h3>Library</h3>
            <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 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="">EXPLORE</a>
        </div>
        <div class="img">
            <img src="./images/b2.jpg" alt="">
        </div>
        <div class="text">
            <h3>Library</h3>
            <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 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="">EXPLORE</a>
        </div>
        <div class="text">
            <h3>Library</h3>
            <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 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="">EXPLORE</a>
        </div>
        <div class="img">
            <img src="./images/b3.jpg" alt="">
        </div>
        <div class="text">
            <h3>Library</h3>
            <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 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="">EXPLORE</a>
        </div>
        <div class="img">
            <img src="./images/b4.jpg" alt="">
        </div>
    </section>
/* 图文混排区域 */
.img-text {
    width: 100%;
    margin-top: 20px;
}
.img-text div {
    width: 25%;
    height: 380px;
    background-color: #07cbc9;
    float: left;
}
.img-text .img img {
    height: 100%;
    width: 100%;
}
.img-text .text h3 {
    font-size: 24px;
    color: white;
    margin-bottom: 30px;
    margin-top: 20px;
    margin-left: 20px;
}
.img-text .text .p1 {
    margin-left: 20px;
    margin-top: 30px;
    margin-bottom: 30px;
    font-size: 16px;
    color: #fff;
}
.img-text .text .p2 {
    color: gray;
    margin-left: 20px;
    font-size: 14px;
    margin-bottom: 30px;
}
.img-text .text a {
    display: block;
    width: 138px;
    height: 40px;
    background-color: #000;
    color: white;
    line-height: 40px;
    text-align: center;
    margin: 0 auto;
}
写回答

1回答

好帮手慕然然

2021-04-27

同学你好,代码实现效果是可以的,基本没有问题。

关于类名的设置,同学的代码中做到了将样式相同的元素设置相同的类名,统一设置样式,所以class类的使用很合理,没有导致代码臃肿。

关于代码中需要优化的地方,同学可以参考以下几点建议:

http://img.mukewang.com/climg/608770230963548f04640196.jpg

http://img.mukewang.com/climg/6087702a0930183c04850271.jpg

http://img.mukewang.com/climg/6087702a0933555305660509.jpg

http://img.mukewang.com/climg/6087702a09d59b4104580324.jpg

​祝学习愉快!

0
hascride
hp>好的,感谢老师的指点!

h021-04-27
共1条回复

0 学习 · 15276 问题

查看课程