Created
November 5, 2012 22:10
-
-
Save joemcgill/4020718 to your computer and use it in GitHub Desktop.
Inline Text Background (CSS only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Class for defining text with background on text only and not the whole block. | |
* May require definition of html element (i.e. p.textbg) in order to make line-height | |
* and font-size work. | |
*/ | |
.textbg { | |
padding:5px 0; /* top and bottom padding */ | |
color:#fff; | |
font-size: 24px; | |
line-height: 48px; /* use this to create horizontal space between lines */ | |
display: inline; | |
background-color:red; | |
box-shadow: 10px 0 0 0 red, -10px 0 0 0 red; /* left/right padding (IE8 needs fallback) */ | |
left:10px; /* match px of box-shadow above to align text */ | |
position: relative; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment