H5、CSS、JS

CSS箭头三角形——茴香豆的几种写法

2016-04-16  本文已影响190人  前端历险记

CSS样式中,难免遇上装饰性的箭头or三角,从实际操作,有以下几种玩法:

优势很明显,速度,但是缺陷也很明显,虽说可调正font-size\color,但自定义方面太局限,往往缺乏设计美感,不符合需求

<!--<div id="triangle-up"></div>-->
#triangle-up{
  width:0;
  height:0;
  border:25px solid transparent;
  border-bottom:50px solid pink;
}

<!--div id="arrow-up">
  <em></em>
</div>-->
#arrow-up{
  position:relative;
  width:0;
  height:0;
  border:50px solid transparent;
  border-bottom:50px solid pink;
}

#arrow-up em{
  position:absolute;
  left:-50px;
  top:-48px;
  width:0;
  height:0;
  border:50px solid transparent;
  border-bottom:50px solid #fff;
}
完整代码在[这里](https://jsfiddle.net/onvno/wbv6ytx2/10/)
箭头的代码是参照了百度首页的效果

参考:
纯CSS绘制三角形(各种角度)
百度

上一篇下一篇

猜你喜欢

热点阅读