css怎么写五角星


本文摘自PHP中文网,作者藏色散人,侵删。

css写五角星的方法:首先创建一个HTML示例文件;然后通过small名class创建div;最后通过设置“transform: rotate(70deg);”等样式来实现五角星即可。

本文操作环境:windows7系统、HTML5&&CSS3版,DELL G3电脑

使用css实现五角星

大五角星

通过small名class创建div

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

.small-all{

display: flex;

margin:1rem 13%;

}

.small {

    border-color: #7d7d7d transparent transparent transparent;

    border-style: solid;

    border-top-width: 9.375px;

    border-right-width: 15px;

    border-left-width: 15px;

    height: 0;

    margin-top: 9.375px;

    margin-bottom: 6.02679px;

    position: relative;

    width: 0;

    margin: 2rem 0.8rem;

}

.small:before,.small:after {

    border-color: #7d7d7d transparent transparent transparent;

    border-style: solid;

    border-top-width: 9.375px;

    border-right-width: 15px;

    border-left-width: 15px;

    content: '';

    display: block;

    height: 0;

    left: -15px;

    position: absolute;

    top: -9.375px;

    width: 0;

}

.small:before {

    transform: rotate(70deg);

}

.small:after {

    transform: rotate(-70deg);

}

实现效果

2239d042f8e333370b2d15b2ecf332a.png

小五角星

通过smaller名class创建div

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

.smaller {

    border-color: #7d7d7d transparent transparent transparent;

    border-style: solid;

    border-top-width: 5px;

    border-right-width: 10px;

    border-left-width: 10px;

    height: 0;

    margin-right: 1.2rem;

    margin-top: 5px;

    margin-bottom: 3.21429px;

    position: relative;

    width: 0;

}

.smaller:before,.smaller:after {

    border-color: #7d7d7d transparent transparent transparent;

    border-style: solid;

    border-top-width: 5px;

    border-right-width: 10px;

    border-left-width: 10px;

    content: '';

    display: block;

    height: 0;

    left: -10px;

    position: absolute;

    top: -5px;

    width: 0;

}

.smaller:before {

    transform: rotate(70deg);

}

.smaller:after {

    transform: rotate(-70deg);

}

实现效果

a9f3b19e1104afd1a5e4c6b5216c528.png

推荐学习:《css视频教程》

以上就是css怎么写五角星的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

如何转换css元素的显示模式

css因mime类型不匹配而被忽略怎么办

css如何控制网页背景颜色

html css js 区别是什么

css怎么设置背景不动

css outline属性怎么用?

css padding-right属性怎么用

怎么给css文件改名

css目标选择器有哪些

css怎么设置分割线

更多相关阅读请进入《css》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...