文字和背景颜色重叠

时间:2017-04-04 18:01:45

标签: css

有背景颜色时文本是否可以重叠?

<span style="font-family: Roboto, sans-serif  !important; font-weight: regular; color=black; background-color:#E0E0E0;  padding: 5px; ">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation </span>

https://jsfiddle.net/z9zbjye3/

1 个答案:

答案 0 :(得分:2)

这是由于span的内联特性。给出一个行高以避免重叠

<span style="font-family: Roboto, sans-serif  !important; 
font-weight: regular; color=black; background-color:#c44dff; 
 padding: 5px;line-height:30px ">Lorem ipsum dolor sit amet,
 consectetur adipiscing elit, sed do eiusmod tempor incididunt
 ut labore et dolore magna aliqua. Ut enim ad minim veniam,
 quis nostrud exercitation </span><br><br>