Created
January 26, 2016 20:45
-
-
Save maxxcrawford/1959df0e661e9651d51a to your computer and use it in GitHub Desktop.
CSS3 - Inline text with padded rows
This file contains hidden or 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
<!DOCTYPE html><html class=''> | |
<head><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="canonical" href="http://codepen.io/df/pen/bfnso" /> | |
<style class="cp-pen-styles">/** | |
* Flexible inline text with background color | |
*/ | |
body { | |
width: 50%; | |
background: #363532; | |
} | |
p { | |
display: inline; | |
font-size: 1.5em; | |
} | |
p, p > span { | |
position: relative; | |
right: 1em; | |
/* 1em right margin (twice the value of the left margin) */ | |
line-height: 2em; | |
padding: .3em 0; | |
/* line padding */ | |
background: #fff; | |
} | |
span > span { | |
position: relative; | |
left: .5em; | |
/* left margin */ | |
} | |
p { | |
left: 1em; | |
/* left margin + right margin */ | |
} | |
</style></head><body> | |
<p> | |
<span><span>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis | |
vestibulum. Morbi leo risus, porta ac consectetur ac, vestibulum | |
at eros. Donec id elit non mi porta gravida at eget metus.</span></span> | |
</p> | |
<script src='//codepen.io/assets/editor/live/css_live_reload_init.js'></script> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment