纯css制作箭头

css制作箭头,下面写了向上箭头的写法

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>向上箭头</title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}

			.top {
				position: absolute;
				margin: 200px;
			}

			.top:before,
			.top:after {
				position: absolute;
				content: '';
				border-top: 10px solid transparent;
				border-bottom: 10px solid red;
				border-left: 10px solid transparent;
				border-right: 10px solid transparent;
			}
			.top:after{
				top: 4px;
				border-bottom: 10px solid #fff;
			}
		</style>
	</head>
	<body>
		<p class="top"></p>
	</body>
</html>

效果如下图所示:
[外链图片转存失败,源站可能有防盗在这里插入!链机制,建描述]议将图片上https://传(imbloQsdnimg.35Dccn/201910081545058.png75703)(https://img-blog.csdnimg.辅导费8154505358.png)]
其他方向同理即可

接下来制作一个箭头的边框

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>向上箭头</title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
			.main{
				margin: 200px;
				position: relative;
			}
			.left {
				position: absolute;
				z-index: 10;
			}

			.left:before,
			.left:after {
				position: absolute;
				content: '';
				border-top: 10px solid transparent;
				border-bottom: 10px solid red;
				border-left: 10px solid transparent;
				border-right: 10px solid transparent;
			}
			.left:after{
				top: 1px;
				border-bottom: 10px solid #fff;
			}
			.box{
				width: 200px;
				height: 200px;
				border: 1px solid red;
				position: absolute;
				top: 20px;
				left: -30px;
			}
		</style>
	</head>
	<body>
		
		<div class="main">
			<p class="left"></p>
			<p class="box"></p>
		</div>
	</body>
</html>

效果如下图所示
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值