有没有办法创建纯CSS2跨浏览器三角形?

时间:2012-08-29 10:19:58

标签: html cross-browser css

就像在标题中说的那样,是否有人知道使用CSS2(而不是CSS3)制作三角形而不使用图像的技巧?

1 个答案:

答案 0 :(得分:5)

在一个好网站上的一个小请求会给出你的答案:

http://css-tricks.com/snippets/css/css-triangle/

.arrow-up {
	width: 0; 
	height: 0; 
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	
	border-bottom: 5px solid black;
}

.arrow-down {
	width: 0; 
	height: 0; 
	border-left: 20px solid transparent;
	border-right: 20px solid transparent;
	
	border-top: 20px solid #f00;
}

.arrow-right {
	width: 0; 
	height: 0; 
	border-top: 60px solid transparent;
	border-bottom: 60px solid transparent;
	
	border-left: 60px solid green;
}

.arrow-left {
	width: 0; 
	height: 0; 
	border-top: 10px solid transparent;
	border-bottom: 10px solid transparent; 
	
	border-right:10px solid blue; 
}
<div class="arrow-up"></div>
<div class="arrow-down"></div>
<div class="arrow-left"></div>
<div class="arrow-right"></div>