复制代码

为懒人提供无限可能,生命不息,code不止

人类感性的情绪,让我们知难行难
我思故我在
日拱一卒,功不唐捐
  • 首页
  • 前端
  • 后台
  • 数据库
  • 运维
  • 资源下载
  • 实用工具
  • 接口文档工具
  • 登录
  • 注册

HTML

【原创】CSS写出小三角

作者: whooyun发表于: 2017-03-21 16:23

<!--向上的三角-->
<div class="arrow-up"></div>

<!--向下的三角-->
<div class="arrow-down"></div>

<!--向左的三角-->
<div class="arrow-left"></div>

<!--向右的三角-->
<div class="arrow-right"></div>


/*箭头向上*/
.arrow-up{ width:200px; height:150px; background:#ECECEC; position:relative;margin-top: 50px;}
.arrow-up:after{
	position: absolute;
	right: 2px;
	top: -20px;
	display: block;
	content: "";
	width: 0;
	height: 0;
	border-left: 20px solid transparent;
	border-right: 20px solid transparent;
	border-bottom: 20px solid #ECECEC;
}              

		
 /*箭头向下*/
.arrow-down{ width:200px; height:150px; background:#ECECEC; position:relative;margin-top: 50px;}
.arrow-down:after{
	position: absolute;
	right: 1px;
	bottom: -20px;
	display: block;
	content: "";
	width:0; 
	height:0; 
	border-left:20px solid transparent;
	border-right:20px solid transparent;
	border-top:20px solid #ECECEC;
}
		
 /*箭头向左*/
.arrow-left{ width:200px; height:150px; background:#ECECEC; position:relative;margin-top: 50px;margin-left: 50px;}
.arrow-left:after{
	position: absolute;
	right: 1px;
	left: -20px;
	display: block;
	content: "";
	width:0; 
	height:0; 
	border-top:20px solid transparent;
	border-bottom:20px solid transparent; 
	border-right:20px solid #ECECEC; 
}
   
/*箭头向右*/
.arrow-right{ width:200px; height:150px; background:#ECECEC; position:relative;margin-top: 50px;}
.arrow-right:after{
	position: absolute;
	right: 1px;
	right: -20px;
	display: block;
	content: "";
	width:0; 
	height:0; 
	border-top:20px solid transparent;
	border-bottom: 20px solid transparent;
	border-left: 20px solid #ECECEC;
}