css制作实心、空心arrow箭头

使用纯CSS,你只需要很少的代码就可以创作出各种浏览器都兼容的三角形箭头CSS代码

效果图:

css制作实心、空心arrow箭头_第1张图片

代码:

  1. lang="en">
  2. charset="UTF-8">
  3. </span><span class="pln" style="color:rgb(0,0,0);">Document</span><span class="tag" style="color:rgb(0,0,136);">
  4. type="text/css">
  5. /*实心箭头*/
  6. .sx-arrow-down{
  7. border-style:solid dashed dashed dashed;
  8. border-width:10px;
  9. border-color:#f00 transparent transparent transparent;
  10. width:0;height:0;
  11. }
  12. .sx-arrow-up{
  13. border-style:dashed dashed solid dashed;
  14. border-color:transparent transparent #f00 transparent;
  15. border-width:10px;
  16. width:0;height:0;
  17. }
  18. .sx-arrow-left{
  19. border-style:dashed dashed dashed solid;
  20. border-color:transparent transparent transparent #f00;
  21. border-width:10px;
  22. width:0;height:0;
  23. }
  24. .sx-arrow-right{
  25. border-style:dashed solid dashed dashed;
  26. border-color:transparent #f00 transparent transparent;
  27. border-width:10px;
  28. width:0;height:0;
  29. }
  30. /* 空心箭头 */
  31. i.kx-arrow{display:block;height:16px;width:16px;float:left;position:relative;
  32. border:1px solid #000;margin-right:5px;
  33. }
  34. em,span{width:0;height:0;
  35. border-color:transparent;
  36. position:absolute;
  37. }
  38.  
  39.  
  40. i.kx-arrow-up em{
  41. border-width:8px; /*边框的高度*/
  42. border-style:solid dashed dashed dashed;
  43. border-top-color:#999; /*边框的颜色*/
  44. top:2px; /*边框的厚度*/
  45. left:0;
  46. }
  47. i.kx-arrow-up span{
  48. border-width:8px; /*边框的高度*/
  49. border-style:solid dashed dashed dashed;
  50. top:0;
  51. left:0;
  52. border-top-color:#fff;/*用白色边框绝对定位盖住多余的部分*/
  53. }
  54.  
  55.  
  56. i.kx-arrow-left em{
  57. border-width:8px; /*边框的高度*/
  58. border-style:dashed dashed dashed solid;
  59. border-left-color:#999; /*边框的颜色*/
  60. top:0;
  61. left:2px; /*边框的厚度*/
  62. }
  63. i.kx-arrow-left span{
  64. border-width:8px; /*边框的高度*/
  65. border-style:dashed dashed dashed solid;
  66. top:0;
  67. left:0;
  68. border-left-color:#fff;/*用白色边框绝对定位盖住多余的部分*/
  69. }
  70.  
  71. i.kx-arrow-right em{
  72. border-width:8px; /*边框的高度*/
  73. border-style:dashed solid dashed dashed;
  74. border-right-color:#999; /*边框的颜色*/
  75. top:0;
  76. right:2px; /*边框的厚度*/
  77. }
  78. i.kx-arrow-right span{
  79. border-width:8px; /*边框的高度*/
  80. border-style:dashed solid dashed dashed;
  81. top:0;
  82. right:0;
  83. border-right-color:#fff;/*用白色边框绝对定位盖住多余的部分*/
  84. }
  85.  
  86. i.kx-arrow-down em{
  87. border-width:8px; /*边框的高度*/
  88. border-style:dashed dashed solid dashed;
  89. border-bottom-color:#999; /*边框的颜色*/
  90. left:0;
  91. bottom:2px; /*边框的厚度*/
  92.  
  93. }
  94. i.kx-arrow-down span{
  95. border-width:8px; /*边框的高度*/
  96. border-style:dashed dashed solid dashed;
  97. left:0;
  98. bottom:0;
  99. border-bottom-color:#fff;/*用白色边框绝对定位盖住多余的部分*/
  100. }
  101.  
  102. /*box-shadow妙用*/
  103. .icon{display:inline-block;width:31px; height:31px;line-height:31px; text-align:center;background:none; margin:50px; border-radius:50%; box-shadow:0 0 0 1px #ccc inset; transition:box-shadow 0.25s ease 0s; position:relative; cursor:pointer;}
  104. .icon:hover{box-shadow: 0 0 0 16px #003366 inset;}
  105. .icon:hover{color:#fff;}
  106. 1、 mk-less教程有三角形制作
  107. 2、三角形制作工具推荐

  108. ======================实心三角形=============
  109. class="sx-arrow-up">

  • class="sx-arrow-down">

  • class="sx-arrow-left">

  • class="sx-arrow-right">
  •  
  • ======================空心三角形=============

  • class="kx-arrow kx-arrow-up">

  • class="kx-arrow kx-arrow-left">

  • class="kx-arrow kx-arrow-right">

  • class="kx-arrow kx-arrow-down">
  •  

  • ======================box-shadow=============

  • class="icon">a
  • 方法二实现空心箭头

    :after

    content: " ";
        display: inline-block;
        height: 6px;
        width: 6px;
        border-width: 2px 2px 0 0;
        border-color: #c8c8cd;
        border-style: solid;
        -webkit-transform: matrix(.71,.71,-.71,.71,0,0);
        transform: matrix(.71,.71,-.71,.71,0,0);
        position: relative;
        top: -2px;
        position: absolute;
        top: 50%;
        margin-top: -4px;
        right: 2px;

    推荐一款箭头自生成工具:

    http://apps.eky.hk/css-triangle-generator/

    http://thx.github.io/cube/doc/layout/#h7  和cube类型的有alice

    你可能感兴趣的:(css3,css)