CSS triangle :before element

后端 未结 3 1745
旧时难觅i
旧时难觅i 2021-01-07 17:07

I\'m using bootstrap, trying to make a div have a CSS triangle before it.

http://jsfiddle.net/B2XvZ/11/

Here is my non-working code:

.d:bef         


        
3条回答
  •  -上瘾入骨i
    2021-01-07 17:23

    You need to specify the content property.

    For positioning, add position:relative to the parent, and then absolutely position the arrow -15px to the left.

    jsFiddle example

    .d {
        position:relative;
    }
    
    .d:before {
        content:"\A";
        border-style: solid;
        border-width: 10px 15px 10px 0;
        border-color: transparent #dd4397 transparent transparent;
        position: absolute;
        left: -15px;
    }
    

提交回复
热议问题