在网页中,你在不少地方都能看到倒三角,好比tooltips,下拉菜单等。你们有几种方式来实现呢?css
1.BASE64编码 图片html
假如你已经有了三角形的图片,而且减小HTTP请求,那么将这个图片转换成一个BASE64字符串是最好的解决方案。web
有用的工具 浏览器
http://webcodertools.com/imagetobase64converter工具
http://image2base64.wemakesites.net/编码
2.CSS 边框spa
<html> <title>倒三角演示代码1</title> <head> <style type="text/css"> .triangleDiv{ border-color: #57af1a #fff #fff #fff; border-style: solid; border-width: 100px 60px 0 60px; height: 0; width: 0; } </style> </head> <body> <div class='triangleDiv'></div> </body> </html>
3.Unicode字符.net
<html> <title>倒三角演示代码2</title> <head> <style type="text/css"> .triangleDiv{ font-size: 18px; color: #f7931d; text-shadow: 0 1px 1px rgb(99, 95, 92); } </style> </head> <body> <span class='triangleDiv'>▼</span> </body> </html>
4.CSS 旋转正方形设计
<html> <title>倒三角演示代码3</title> <head> <style type="text/css"> .parentDiv { height: 14px; overflow: hidden; } .triangleDiv { position: relative; height: 20px; width: 12px; top: -12px; left: 7px; background: #0c0c0c; -moz-transform: rotate(45deg); -webkit-transform: rotate(45deg); -o-transform: rotate(45deg); transform: rotate(45deg); } </style> </head> <body> <div class="parentDiv"> <div class="triangleDiv"></div> </div> </body> </html>