如何用纯css画个三角形

6 篇文章 1 订阅
2 篇文章 0 订阅

网站前台开发的同胞们,你们是不是发现在某些侧边栏的每个标题的左边有个很小的三角形,默认状态下小三角形尖朝右,当鼠标移上去时,小三角形尖朝下。大家知道,这是图片而已。可是这里要给你们介绍的是不用图片,纯css实现小三角形。

请看下图:

e.jpg (77×229)

何止是朝右朝下的三角形,朝左朝右也行啊。代码如下:

<style type="text/css">
.rightdirection
{
	width:0;height:0;
	line-height:0;
	border-width:20px;
	border-style:solid;
	border-color:transparent transparent transparent #A9DBF6;
}
.bottomdirection
{
	width:0;height:0;
	line-height:0;
	border-width:20px;
	border-style:solid;
	border-color: #A9DBF6 transparent transparent transparent;
}
.leftdirection
{
	width:0;height:0;
	line-height:0;
	border-width:20px;
	border-style:solid;
	border-color: transparent #A9DBF6 transparent transparent;
}
.topdirection
{
	width:0;height:0;
	line-height:0;
	border-width:20px;
	border-style:solid;
	border-color: transparent transparent #A9DBF6 transparent;
}
</style>
<div  class="rightdirection"></div>
<p>
<div  class="bottomdirection"></div>
<p>
<div  class="leftdirection"></div>
<p>
<div  class="topdirection"></div>

其中三角形的大小和颜色可以根据需要随意修改。

  • 5
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值