老师帮忙看下这样做对不对,有没有冗余代码,哪里需要优化?

来源:2-8 过渡效果实战课(1)

weixin_慕码人7523200

2020-11-04 21:25:02

# 具体遇到的问题

# 报错信息的截图

# 相关课程内容截图

# 尝试过的解决思路和结果

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

<!DOCTYPE html>

<html lang="en">


<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

    <style>

        .box {

            width700px;

            height200px;

            margin100px auto;

        }

        

        .box .box1 {

            floatleft;

            positionrelative;

            width200px;

            height200px;

            overflowhidden;

        }

        

        .box .box1+.box1 {

            margin-left50px;

        }

        

        .box .box1 img {

            width200px;

            height200px;

        }

        

        .box .box1 span:nth-of-type(1) {

            positionabsolute;

            bottom0;

            width200px;

            height30px;

            background#000;

            colorwhite;

            text-aligncenter;

            line-height30px;

            opacity0;

            transition: opacity 1s linear 0s;

        }

        

        .box .box1:hover span:nth-of-type(1) {

            opacity1;

        }

        

        .box .box1 span:nth-of-type(2) {

            positionabsolute;

            top-30px;

            width200px;

            height30px;

            background#000;

            colorwhite;

            text-aligncenter;

            line-height30px;

            transitiontop .5s linear 0s;

        }

        

        .box .box1:hover span:nth-of-type(2) {

            top0;

        }

    </style>

</head>


<body>

    <div class="box">

        <div class="box1">

            <span>我是底部淡入文字</span>

            <span>我是顶部hidden文字</span>

            <img src="../images/03-04.jpg" alt="">

        </div>

        <div class="box1">

            <span>我是底部淡入文字</span>

            <span>我是顶部hidden文字</span>

            <img src="../images/news_pic.png" alt="">

        </div>

        <div class="box1">

            <span>我是底部淡入文字</span>

            <span>我是顶部hidden文字</span>

            <img src="../images/cos.jpg" alt="">

        </div>

    </div>

</body>


</html>


写回答

1回答

好帮手慕夭夭

2020-11-05

同学你好,代码实现正确,也挺简洁,不用修改了。祝学习愉快~

0

0 学习 · 15276 问题

查看课程