网站前台开发的同胞们,你们是不是发现在某些侧边栏的每个标题的左边有个很小的三角形,默认状态下小三角形尖朝右,当鼠标移上去时,小三角形尖朝下。大家知道,这是图片而已。可是这里要给你们介绍的是不用图片,纯css实现小三角形。
请看下图:
何止是朝右朝下的三角形,朝左朝右也行啊。代码如下:
<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>其中三角形的大小和颜色可以根据需要随意修改。