2-7 五角星角度精准实现
首先这不是一个问题,这是一个关于五角星的画法的分享,
最后的顶角测量有两度的误差,不知道是测量误差还是画法误差;
如果各位有发现的问题,欢迎提出;
五角星分解:
整个五角星就是这个三角形绕自己高的百分之二十的地方旋转72°实现的;
可能旋转的中心点高低有所不同,可以自己调整,但是整体角度绝对正确,
顶角36°;宽高比2:3;
完整代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | <!DOCTYPE HTML> < html > < head > < meta charset = "utf-8" > < title >五星红旗</ title > < style type = "text/css" > .box { height: 800px; width: 800px; position: relative; margin: 50px auto; border: 1px solid black; } .one { margin: 30%; width: 0px; height: 0px; position: absolute; border-bottom: 300px solid yellow; border-left: 100px solid transparent; border-right: 100px solid transparent; transform-origin: 50% 80%; } .two { margin: 30%; width: 0px; height: 0px; position: absolute; border-bottom: 300px solid yellow; border-left: 100px solid transparent; border-right: 100px solid transparent; transform-origin: 50% 80%; transform: rotate(72deg); } .three { margin: 30%; width: 0px; height: 0px; position: absolute; border-bottom: 300px solid yellow; border-left: 100px solid transparent; border-right: 100px solid transparent; transform-origin: 50% 80%; transform: rotate(-72deg); } .four { margin: 30%; width: 0px; height: 0px; position: absolute; border-bottom: 300px solid yellow; border-left: 100px solid transparent; border-right: 100px solid transparent; transform-origin: 50% 80%; transform: rotate(144deg); } .five { margin: 30%; width: 0px; height: 0px; position: absolute; border-bottom: 300px solid yellow; border-left: 100px solid transparent; border-right: 100px solid transparent; transform-origin: 50% 80%; transform: rotate(-144deg); } </ style > </ head > < body > < div class = "box" > < div class = "one" ></ div > < div class = "two" ></ div > < div class = "three" ></ div > < div class = "four" ></ div > < div class = "five" ></ div > </ div > </ body > </ html > |
39
收起
正在回答
1回答
你好,实现效果没有问题,由于代码的灵活性,实现效果的方式有很多种,谢谢你分享的思路,棒棒的!~
祝学习愉快!
响应式开发与常用框架 2018
- 参与学习 人
- 提交作业 2198 份
- 解答问题 5012 个
如果你有web端基础,既想进阶,又想进军移动端开发,那就来吧,我们专题为你带来的课程有HTML5、CSS3、移动基础、响应式、bootstrap、less等,让你在前端道路上畅通无阻!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧