How to add badge on top of Font Awesome symbol?

后端 未结 5 807
温柔的废话
温柔的废话 2020-12-12 10:56

I would like to add badge with some number (5, 10, 100) on top of the Font Awesome symbol (fa-envelope). For example:

5条回答
  •  佛祖请我去吃肉
    2020-12-12 11:13

    Wrap the fa-envelope and the span containing the number in a div and make the wrapper div position:relative and the span position:absolute.

    Check this fiddle

    HTML used

    100

    CSS

    .icon-wrapper{
        position:relative;
        float:left;
    }
    
    *.icon-blue {color: #0088cc}
    *.icon-grey {color: grey}
    i {   
        width:100px;
        text-align:center;
        vertical-align:middle;
    }
    .badge{
        background: rgba(0,0,0,0.5);
        width: auto;
        height: auto;
        margin: 0;
        border-radius: 50%;
        position:absolute;
        top:-13px;
        right:-8px;
        padding:5px;
    }
    

    Hope this might help you

提交回复
热议问题