用 CSS 画三角形

宽度和高度都为0的box

箭头的实际宽度和高度由边框的宽度来决定。例如,在一个向上的箭头中,底部边框是有颜色的,左侧和右侧是透明的,组成了三角形:

.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; 
}

CSS Triangle CSS3 Shapes

results matching ""

    No results matching ""