简体   繁体   中英

How to create arrow with border with CSS

How to make an arrow like in the picture below? 例子

I've created a codepen using clippath, let me know if that works.

https://codepen.io/_makki/pen/BawgmVJ

<div>
    <span>Some Text</span>
</div>

div {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    width: 150px;
    position: relative;
    background: black;
    clip-path: polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 15% 50%, 0% 0%);
}

div:before {
    content: "";
    background: white;
    height: calc(100% - 2px);
    width: calc(100% - 3px);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    clip-path: polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 15% 50%, 0% 0%);
}

div span {
    z-index: 2;
    position: relative;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM