If you are not using <p> (only <div> and <span> s), this solution may even allow you to align your inline-block center or right if you want (or just keep them left, as you were asked) . Although the solution may still work with <p> s, I donβt think the resulting HTML would be completely correct, but itβs all the same.
The trick is to wrap each of your <span> with the appropriate <div> . Thus, we use a line break caused by <div> display: block (by default), while maintaining the visual green box to the limits of the text (with the declaration display: inline-block ).
.text span { background:rgba(165, 220, 79, 0.8); display:inline-block; padding:7px 10px; color:white; } .large { font-size:80px }
<div class="text"> <div><span class="medium">We</span></div> <div><span class="large">build</span></div> <div><span class="medium">the</span></div> <div><span class="large">Internet</span></div> </div>
Rui Pimentel Nov 28 '16 at 19:38 2016-11-28 19:38
source share