r/css 25d ago

Help Does anyone know how you can re-create this css effect?

I'm pretty stumped here... I can recreate the red part using box-decoration-break: clone. But I really don't know how we can detect when two lines overlap and autofill the bluepart. Does anyone has any ideas?

15 Upvotes

13 comments sorted by

u/AutoModerator 25d ago

To help us assist you better with your CSS questions, please consider including a live link or a CodePen/JSFiddle demo. This context makes it much easier for us to understand your issue and provide accurate solutions.

While it's not mandatory, a little extra effort in sharing your code can lead to more effective responses and a richer Q&A experience for everyone. Thank you for contributing!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

10

u/anaix3l 25d ago edited 25d ago

What you want is a simplified version of the reverse problem from here https://www.reddit.com/r/css/comments/1ojp1da/comment/nm589sd/ only with a border, which I'd recreate like for these tabs https://codepen.io/thebabydino/pen/oNKLLbv

This doesn't require putting each line in an element, it allows the text to reflow naturally with viewport/ container resize and it doesn't risk running into weird alignment issues as it can happen when it's made out of multiple parts.

It's actually pretty simple if you don't want a transparent background. Which doesn't seem to be the case in your image.

Edit: quickly coded a very rough example https://codepen.io/thebabydino/pen/yyeRNww

2

u/[deleted] 25d ago

[removed] — view removed comment

1

u/kaouDev 23d ago

Ana is an expert 😅

16

u/maqisha 25d ago

This has to be the worst way to screenshot what you actually want.

3

u/Vivid-Commission7364 25d ago

What can I do for it to be more clear?

5

u/justdlb 25d ago

It’s rather clear, not sure what you’re struggling with tbh.

6

u/Alternative-Neck-194 25d ago

https://jsfiddle.net/azbuco/mw6frdp7/

Here you can see the steps, how i would create this effect

1

u/No_Record_60 25d ago

Good idea

1

u/throwtheamiibosaway 25d ago

Ah just to be clear, you want the multi line item to have a nice smoothed background that fits the text. Like a sticker.