如何使用CSS制作箭头符号


本文摘自PHP中文网,作者不言,侵删。

箭头符号我们是经常可以看到的,那么我们如何在不利用图像的情况下使用CSS制作箭头符号呢?本篇文章就来给大家介绍CSS制作箭头符号的方法。

箭头

话不多说,下面我们直接来看正文~

用CSS制作的箭头图标的方法

只需要使用CSS就可以创建箭头而不需要利用图像

首先,让我们来看看如何实现一个箭头,我将来制作一个从左上角到右下角的L形箭头。

一个直角转弯的箭头。

代码如下

HTML代码

1

2

3

4

5

6

7

8

9

10

11

12

<!DOCTYPE html>

<html>

  <head>

  <meta charset="utf-8">

    <title>CSS arrow</title>

    <link rel="stylesheet" type="text/css" href="sample.css">

   <meta http-equiv="Content-Type" content="text/html" charset="UTF-8">

  </head>

  <body>

   <div class="arrow"></div>

  </body>

</html>

CSS代码

sample.css

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

.arrow{

  position: relative;

  width: 200px;

  height: 50px;

  border-top: 8px solid #5bc0de;

  border-right: 8px solid #5bc0de;

  box-sizing: border-box;

}

.arrow::after{

  content: "";

  position: absolute;

  bottom: -14px;

  right: -17px;

  border-top: 14px solid #5bc0de;

  border-left: 14px solid transparent;

  border-right: 14px solid transparent;

}

运行结果

在浏览器上显示如下效果

箭头

接下来介绍的几种箭头符号的制作HTML代码与上述相同,我们主要通过更改CSS代码来实现

三角形的箭头

CSS代码

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

.arrow{

  position: relative;

  display: inline-block;

  padding: 0 0 0 16px;

  color: #000;

  vertical-align: middle;

  text-decoration: none;

  font-size: 15px;

}

 

.arrow::before{

  position: absolute;

  top: 0;

  bottom: 0;

  left: 0;

  margin: auto;

  content: "";

  vertical-align: middle;

  box-sizing: border-box;

  width: 12px;

  height: 12px;

  border: 1px solid #ff0000;

  -webkit-border-radius: 25%;

  border-radius: 25%;

}

 

.arrow::after{

  position: absolute;

  top: 0;

  bottom: 0;

  left: 0;

  margin: auto;

  content: "";

  vertical-align: middle;

  left: 5px;

  box-sizing: border-box;

  width: 3px;

  height: 3px;

  border: 3px solid transparent;

  border-left: 3px solid #ff0000;

}

运行效果如下

阅读剩余部分

相关阅读 >>

css border-image属性怎么用

css盒子中的图如何居中

css li怎么水平居中对齐

css全局样式有什么意义

css怎么改字位置

css怎么实现字体描边效果

手机端怎样用rem+scss做适配

css怎么调整字体

一招搞定css相对原点定位背景图片

css 如何实现让文字滑入的方式

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




打赏

取消

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

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

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

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

评论

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