美文网首页
css写箭头,三角形

css写箭头,三角形

作者: plum_meizi | 来源:发表于2020-01-07 11:47 被阅读0次

    箭头

    向上的箭头
    image.png
    .icon-up {
        display: inline-block;
        width: 10px;
        height: 10px;
        border-left: 2px solid #999;
        border-top: 2px solid #999;
        transform: rotate(45deg);
    }
    

    如果想得到其他方向的箭头,只需要转动角度就可transform: rotate(45deg);

    .icon-right {
        display: inline-block;
        width: 10px;
        height: 10px;
        border-left: 2px solid #999;
        border-top: 2px solid #999;
        transform: rotate(135deg);
    }
    .icon-down {
        display: inline-block;
        width: 10px;
        height: 10px;
        border-left: 2px solid #999;
        border-top: 2px solid #999;
        transform: rotate(225deg);
    }
    .icon-left {
        display: inline-block;
        width: 10px;
        height: 10px;
        border-left: 2px solid #999;
        border-top: 2px solid #999;
        transform: rotate(315deg);
    }
    

    这样就得到了上下左右的箭头,如图:


    image.png

    三角形

    image.png
    .icon-up {
        display: inline-block;
        width: 0;
        height: 0;
        border-right: 10px solid transparent;
        border-left: 10px solid transparent;
        border-bottom: 10px solid red;
    }
    .icon-right {
        display: inline-block;
        width: 0;
        height: 0;
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-left: 10px solid red;
    }
    .icon-down {
        display: inline-block;
        width: 0;
        height: 0;
        border-right: 10px solid transparent;
        border-left: 10px solid transparent;
        border-top: 10px solid red;
    }
    .icon-left {
        display: inline-block;
        width: 0;
        height: 0;
        border-top: 10px solid transparent;
        border-bottom: 10px solid transparent;
        border-right: 10px solid red;
    }
    

    相关文章

      网友评论

          本文标题:css写箭头,三角形

          本文链接:https://www.haomeiwen.com/subject/dbiooctx.html