CSS triangle custom border color

后端 未结 5 1033
情话喂你
情话喂你 2020-11-22 13:28

Attempting to use a custom hex color for my css triangle (border). However since it uses border properties I am unsure how to go about doing this. I would like to steer clea

5条回答
  •  梦谈多话
    2020-11-22 13:41

    You actually have to fake it with two triangles....

    .container {
        margin: 15px 30px;
        width: 200px;
        background: #fff;
        border: 1px solid #a00;
        position: relative;
        min-height: 200px;
        padding: 20px;
        text-align: center;
        color: #fff;
        font: bold 1.5em/180px Helvetica, sans-serif;
        text-shadow: 0 0 1px #000;
    }
    
    .container:after,
    .container:before {
        content: '';
        display: block;
        position: absolute;
        left: 100%;
        width: 0;
        height: 0;
        border-style: solid;
    }
    
    .container:after {
        top: 10px;
        border-color: transparent transparent transparent #fdd;
        border-width: 10px;
    }
    
    .container:before {
        top: 9px;
        border-color: transparent transparent transparent #a00;
        border-width: 11px;
    }
    

    Updated Fiddle here

提交回复
热议问题