How can i make this text background with css only?
almost 8 years ago from Viktor Geringer, Webdesigner/Webdev
almost 8 years ago from Viktor Geringer, Webdesigner/Webdev
When did DN become Stack Exchange?
This is a good thing
It's cool but I can see this getting abused so fast. I don't think the intention of Designer News is to provide people with a platform to get CSS problems solved
i dunno, there's an icon for CSS ... so I'm not sure it's outside of the realm of DN.
Here's one way of doing it. There's probably better ways but it give the right effect. It won't grow with the text so you'll have to adjust the height and top properties accordingly:
edit
Here's a better variation using gradient backgrounds (see the second solution):
http://jsfiddle.net/y4Lae2r9/2/
It doesn't require positioning like the first method and it'll grow with the text size and follow the text over multiple rows.
Damn! I was trying to figure out the text wrapping thing on my own site. Thanks!
Absolutely in love with the typefaces you're using here. Is this site already live?
No but thank you :) It will be soon and I'll post it on DN.
I'd use the :after selector, which is very useful and let you keep a clean HTML.
Example: http://codepen.io/anon/pen/MwePJp
I reached a similar outcome.
http://codepen.io/ljcl/pen/KpMGag
You're going to have a problem if your highlight effect spans more than two rows of text though.
Yes, your solution is actually nicer for long paragraphs. :)
A couple weeks ago I made this using the pseudo elements method as well!
This is nice, going to use similar effect in one of my projects.
Designer News
Where the design community meets.
Designer News is a large, global community of people working or interested in design and technology.
Have feedback?
Login to Comment
You'll need to log in before you can leave a comment.
LoginRegister Today
New accounts can leave comments immediately, and gain full permissions after one week.
Register now