CSS: highlighted text effect

后端 未结 5 993
一个人的身影
一个人的身影 2021-01-13 17:48

I\'m trying to produce a highlighted text effect with a bit of padding, but the padding is only applied to the beginning and end, not new lines.

#highlight {         


        
5条回答
  •  迷失自我
    2021-01-13 18:32

    Try setting the display on your span to inline-block:

    #highlight {
        background: rgba(255, 230, 0, 0.5);
        padding: 3px 5px;
        margin: -3px -5px;
        line-height: 1.7;
        border-radius: 3px;
        display:inline-block;
    }
    

    jsFiddle example

提交回复
热议问题