I got a CSS question related to this fiddle: http://jsfiddle.net/r584e/
Here the relevant screenshot
Sometimes I've got to style an inline element in a such way, trying to almost avoid space between rows and applying a background only under the text. As you can see, the first paragraph has a link inside, in which I set line-height: 1em
. The paragraph on the right has instead a line-height: 0.8em;
. (Note: I know in this way I could roughly cut some letters - like q,g,p,... but the text is uppercase so it's not really a problem)
In the second paragraph rows are actually closer (as I want) but unfortunately each row is also partially overlapping the previous one (unless you remove the background color applied) and this is not good (e.g. see the word «uppercase» on the bottom), so here my questions:
Feel free to change the CSS and/or markup. I'm looking for a pure CSS workaround.
An optimal solution should work on modern browser and, if possible, at least from IE8+
Thank you in advance. =)
Edit:
About 2nd question, using @thirtydot solution I can add space (to the right) using white-space: pre-wrap
applied on the span element
To set the background color with inline styles in React: Set the style prop on the element. Set the backgroundColor property to the specific color.
You could create the divs with absolute position and add a positive z-index to the one you want to be in front. You could put the widths of the container and of the divs with percentages instead of fixed values. e.g. container width: 100%, #left width 60% and #right width 60%.
Simply add a wrapper element inside the em
, such as a span
, and apply position: relative
.
See: http://jsbin.com/axefaf
<a href="#"><em style="line-height: 0.8em">
<span>This is an uppercase multirow text inside a link element</span>
</em></a>
span {
position: relative;
}
This works in all modern browsers and IE8, but does not work in IE7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With