常用的小箭头
<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>三种纯CSS实现三角形的方法</title> <style type="text/css"> .message-box { position:relative; float:left; margin:80px 0 0 100px; width:240px; height:60px; line-height:60px; background:#E9FBE4; box-shadow:1px 2px 3px #E9FBE4; border:1px solid #C9E9C0; border-radius:4px; text-align:center; color:#0C7823; } /*border模拟tips IE9以上才支持*/ .triangle-border { position:absolute; right:50px; overflow:hidden; width:0; height:0; border-width:10px; border-style:solid dashed dashed dashed; } .tb-border { top:-20px; border-color:transparent transparent #C9E9C0 transparent; } .tb-background { top:-19px; border-color:transparent transparent #E9FBE4 transparent; } /*字符模拟tips 全部都兼容*/ .triangle-character { position:absolute; left:60px; overflow:hidden; width:26px; height:26px; font:normal 26px "宋体"; } .tc-background { top:-13px; color:#E9FBE4; } .tc-border { top:-14px; color:#C9E9C0;} /*css3 transfrom 模拟tips left:6px\0;//正对IE浏览器 left:-8px;top:30px; 调整小箭头方向 IE9以上才支持*/ .triangle-css3 { position:absolute; left:-8px; left:-8px\0; top:30px; overflow:hidden; width:13px; height:13px; background:#E9FBE4; border-bottom:1px solid #C9E9C0; border-right:1px solid #C9E9C0;} .transform { -webkit-transform:rotate(135deg); -moz-transform:rotate(135deg); -o-transform:rotate(135deg); transform:rotate(135deg); } /*ie7-9*/ .ie-transform-filter { -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865475, M12=-0.7071067811865477, M21=0.7071067811865477, M22=0.7071067811865475, SizingMethod='auto expand')"; filter: progid:DXImageTransform.Microsoft.Matrix( M11=0.7071067811865475,M12=-0.7071067811865477,M21=0.7071067811865477,M22=0.7071067811865475,SizingMethod='auto expand'); } </style> </head> <body> <div class="message-box"> <span>我是利用 border 属性实现的</span> <div class="triangle-border tb-border"></div> <div class="triangle-border tb-background"></div> </div> <div class="message-box"> <span>我是利用 ◆ 字符实现的</span> <div class="triangle-character tc-border">◆</div> <div class="triangle-character tc-background">◆</div> </div> <div class="message-box"> <span>我是利用 css transfrom 属性实现的</span> <div class="triangle-css3 transform ie-transform-filter"></div> </div> </body> </html>