html - How to include padding on a span element that has multiple lines -


jsfiddle here.

i have span element highlighted using background-color: yellow , padding: 1px 10px.

normal here

however, on smaller devices, line of text becomes 2 lines, 3 lines, etc. causes first , second lines 'lose' padding on right side, such words "the" , "to", , second , third lines 'lose' padding on left side, such words "highlight" , "better" in picture below:

the problem

how can ensure these words (in picture above, "the", "highlight", "to", "better") and other words keep 10px padding on left , right side?

someone in response similar question suggested using display: block, makes span no longer span, rectangle , not how need look. makes highlight span entire width of page.

undesired result

you can try faking background when span broken using box-shadow. try , see if works you:

span {     background-color: yellow;     padding: 1px 0;     box-shadow: 10px 0 0 0 yellow, -10px 0 0 0 yellow; } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -