I am basically trying to do THIS with a paragraph that contains text-indent, but can't get it because the display:inline won't allow text-indent. Any ideas?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
Without br tag : demo here : http://jsfiddle.net/korigan/jzm3qu1q/1/
HTML
CSS
Using pseudo elements
I've created a JSFiddle example that uses
span
elements which areinline
and then addsbefore
andafter
pseudo elements to add additional spacing in front and at the end of each highlighted block of text.In case you need to manipulate amount of that space adjust
font-size
within those pseudo elements and you should be good to go.The trick is just:
Controlling space amount
Using appropriate character(s) in
:before
and:after
pseudo elements one can actually control amount of added spacing down to individual pixels.The best way is to use
thin space
which is in typographical terms 1/5 or sometimes 1/6 of an em. If we setfont-size
of these two pseudo elements to 6 pixels thin space should always approximate to 1 pixel width regardless of dimension discrepancies.Upper style definition will add 1 pixel of space on each side. If we put 5 thin spaces in content, we'd get 5 pixel space...
Or use one thin space and add padding to it and control its width this way. Or even abolish any content and just use padding:
However one does it it's possible to control amount of space down to pixel granularity.