老师请问这样做对不对?怎么做才是正确的,有完整代码吗?

来源:2-13 编程练习

weixin_慕码人7523200

2020-11-02 21:52:55

# 具体遇到的问题

# 报错信息的截图

# 相关课程内容截图

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

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

<!DOCTYPE html>

<html lang="en">


<head>

    <meta charset="UTF-8">

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

    <title>五星红旗</title>

    <style>

        .red {

            positionrelative;

            width600px;

            height400px;

            background-colorred;

            margin100px auto;

        }

        

        .star1 {

            positionabsolute;

            top80px;

            left80px;

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star1::before {

            content"";

            positionabsolute;

            top-71px;

            left-70px;

            transformrotateZ(66deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star1::after {

            content"";

            positionabsolute;

            top-93px;

            left-77px;

            transformrotateZ(134deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star2 {

            positionabsolute;

            top20px;

            left180px;

            transformscale(.5rotateZ(35deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star2::before {

            content"";

            positionabsolute;

            top-71px;

            left-70px;

            transformrotateZ(66deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star2::after {

            content"";

            positionabsolute;

            top-93px;

            left-77px;

            transformrotateZ(134deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star3 {

            positionabsolute;

            top55px;

            left217px;

            transformscale(.5rotateZ(75deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star3::before {

            content"";

            positionabsolute;

            top-71px;

            left-70px;

            transformrotateZ(66deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star3::after {

            content"";

            positionabsolute;

            top-93px;

            left-77px;

            transformrotateZ(134deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star4 {

            positionabsolute;

            top108px;

            left199px;

            transformscale(.5rotateZ(75deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star4::before {

            content"";

            positionabsolute;

            top-71px;

            left-70px;

            transformrotateZ(66deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star4::after {

            content"";

            positionabsolute;

            top-93px;

            left-77px;

            transformrotateZ(134deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star5 {

            positionabsolute;

            top150px;

            left150px;

            transformscale(.5rotateZ(75deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star5::before {

            content"";

            positionabsolute;

            top-71px;

            left-70px;

            transformrotateZ(66deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

        

        .star5::after {

            content"";

            positionabsolute;

            top-93px;

            left-77px;

            transformrotateZ(134deg);

            width0;

            height0;

            border50px solid transparent;

            border-top-coloryellow;

        }

    </style>

</head>


<body>

    <div class="red">

        <div class="star1"></div>

        <div class="star2"></div>

        <div class="star3"></div>

        <div class="star4"></div>

        <div class="star5"></div>

    </div>

</body>


</html>


写回答

1回答

好帮手慕言

2020-11-03

同学你好,解答如下:

1、整体效果是可以的。如果再完善一下五角星的形状会更好。例如:

.star1 {
            position: absolute;
            width: 0;
            height: 0;
            top: 60px;
            border-left: 100px solid transparent;
            border-right: 100px solid transparent;
            border-bottom: 80px solid yellow;
            transform: rotate(35deg) scale(0.5);
        }

        .star1::before {
            content: "";
            position: absolute;
            left: -100px;
            top: 0;
            width: 0;
            height: 0;
            border-left: 100px solid transparent;
            border-right: 100px solid transparent;
            border-bottom: 80px solid yellow;
            transform: rotate(-70deg);
        }

        .star1::after {
            content: "";
            position: absolute;
            left: -63px;
            top: -47px;
            width: 0;
            height: 0;
            border-left: 30px solid transparent;
            border-right: 30px solid transparent;
            border-bottom: 80px solid yellow;
            transform: rotate(-35deg);
        }

2、编程题是没有完整代码的,因为代码很灵活,实现的方式不是唯一的。在学习阶段 , 鼓励大家先独立思考并完成效果 。做完之后存在疑惑的 ,可以在问答区域提问 ,老师会针对你的代码进行指导 , 这样能够了解同学具体哪里掌握的不好 ,有针对性的为你指导 。同学也能通过老师的指导,锻炼自己独立思考与编码的能力,才能更好的帮助你去成长 。

祝学习愉快~


0

0 学习 · 15276 问题

查看课程