开发者

pretty html highlighting using <span>

开发者 https://www.devze.com 2023-02-14 04:46 出处:网络
I\'m highlighting text in a HTML document using <span> tags around the content to be highlighted.The span class has a background-color defined, and a border-radius is also set.This works well.

I'm highlighting text in a HTML document using <span> tags around the content to be highlighted. The span class has a background-color defined, and a border-radius is also set. This works well.

I'd like the highlight to开发者_JAVA技巧 extend a bit further beyond the normal extents of the <span> content. That is, a few pixels to the left of the span-start, and a few pixels to the right of the span-end. Ideally I'd do this without spacing apart the content itself.

Any good css tricks I can use to achieve this?


You can set a padding and a negative margin. For example:

span {
    margin: -5px;
    padding: 5px;
}

You can see a demo here.


margin: 10px 0px; ??

if this does not solve your issue can you elaborate on the problem ?

0

精彩评论

暂无评论...
验证码 换一张
取 消