CSS - apply padding to inline element across two lines

前端 未结 10 944
梦如初夏
梦如初夏 2020-12-29 11:29

I have to create a style to apply a background color and padding to a header element, resulting the following intended appearance (Photoshop mock-up):

My CSS

10条回答
  •  春和景丽
    2020-12-29 12:03

    Demo here : http://jsfiddle.net/korigan/jzm3qu1q/1/

    HTML

     

    Amet assumenda atque eos excepturi harum ipsa

    CSS

    .wrap {
        width: 150px;
    }
    .highlight {
        color: #fff;
        display: inline;
        background: blue;
        font-size: 25px;
        font-weight: normal;
        line-height: 1.2;
    }
    .highlight .text {
            padding: 4px;
            box-shadow: 4px 0 0 blue, -4px 0 0 blue;
            background-color: blue;
            box-decoration-break: clone; /* For Firefox */
    }
    

提交回复
热议问题