Pointed/angled arrow-style borders in CSS

前端 未结 3 2109
我寻月下人不归
我寻月下人不归 2021-02-05 21:46

I\'m making a breadcrumb menu and attempting to do it in pure CSS so I don\'t have to use a background image to get an arrow shape. Is it possible to achieve this angled border

3条回答
  •  心在旅途
    2021-02-05 22:11

    Stealing from CSS Tricks - CSS Triangle, you can do something like

    li.breadcrumb:after {
        content: "";
        display: inline-block;
        width: 0;
        height: 0;
        border-top: 20px solid #eee;
        border-bottom: 20px solid #eee;
        border-left: 20px solid #ccc;
    }
    

    li.breadcrumb:after {
        content: "";
        display: inline-block;
        width: 0;
        height: 0;
        border-top: 20px solid #eee;
        border-bottom: 20px solid #eee;
        border-left: 20px solid #ccc;
    }
    li.first-crumb:after {
        border-top: 20px solid #ccc;
        border-bottom: 20px solid #ccc;
        border-left: 20px solid #aaa;
    }
    li.last-crumb:after {
        border-top: 20px solid #fff;
        border-bottom: 20px solid #fff;
        border-left: 20px solid #eee;
    }
    
    li.breadcrumb {
        list-style-type: none;
        background-color: #ccc;
        display: inline-block;
        float: left;
        line-height: 0;
    }
    li.first-crumb {
        background: #aaa;
    }
    li.last-crumb {
        background: #eee;
    }
    li.breadcrumb a {
        text-decoration: none;
    }
    
    


    Original JSFiddle

提交回复
热议问题