CSS: highlighted text effect

萝らか妹 提交于 2019-12-01 06:18:44

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

If you're not limited to a specific HTML standard, you could take a look at the <mark> tag, which was introduced with HTML5. This site gives you a quick overlook.

Hope it helps!

You need to set the display to inline-block or block.

#highlight {
    display: inline-block;
    /* ... */
}

In case anyone is still looking for an answer:

p {
    box-shadow: 0px 0px 0px 5px yellow;
    display: inline;
    line-height: 2;
    margin: -5px -5px;
    background-color: yellow;
    border-radius: 1px;
}

See jsfiddle here.

Solution is this CSS:

-webkit-box-decoration-break: clone;
box-decoration-break: clone;
display: inline;

https://css-tricks.com/almanac/properties/b/box-decoration-break/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!