Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-backgrounds-4] Can you chain border-area and text in background-clip? #10696

Open
nt1m opened this issue Aug 6, 2024 · 7 comments
Open

Comments

@nt1m
Copy link
Member

nt1m commented Aug 6, 2024

#9456 added background-clip: border-area.

I think it would be useful to support background-clip: border-area text in case you want your background to bleed through both the text and the border-area of an element.

The new syntax would then be:

<bg-clip> = <visual-box> | [ border-area || text ]
@smfr
Copy link
Contributor

smfr commented Aug 6, 2024

I think this is just two border-images:

            background-image: linear-gradient(to bottom right, green, blue), linear-gradient(to bottom right, green, blue), none;
            background-color: yellow;
            background-origin: border-box;
            background-clip: border-area, text, border-box;
@nt1m nt1m closed this as completed Aug 6, 2024
@yisibl
Copy link
Contributor

yisibl commented Aug 12, 2024

Considering that the border gradient uses the same gradient as the text, and to avoid writing multiple background-image, I think it's necessary to support the background-clip: border-area text syntax.

cc @LeaVerou

image

@LeaVerou
Copy link
Member

Agreed. Though my preference would be to not special case the combination of border-area and text, but to define a more general way to create unions of these. Possibly just by space-separating the identifiers. Sure, that could allow nonsensical combinations like border-box content-box but UAs can easily short-circuit those. E.g. border-box text is not meaningless, since text can actually overflow its container (though currently text is clipped by border-box, which is very unfortunate).

@nt1m
Copy link
Member Author

nt1m commented Aug 12, 2024

Feel free to reopen if you feel like this is a path exploring

@LeaVerou LeaVerou reopened this Aug 12, 2024
@SebastianZ
Copy link
Contributor

I guess that's a straight-forward change and all seem positive about it. So let's put it on the agenda.

The two points to resolve on:

  1. Support for multiple values in background-clip
  2. Support any keyword combination or only sensible ones?

Regarding combinations, I don't see value in allowing all combinations. So I propose the syntax to be

<bg-clip> = [ <visual-box> | border-area ] || text

Or, if we believe there are use cases to combine styling the box areas with the border area, then

<bg-clip> = <visual-box> || border-area || text

Sebastian

@Loirooriol
Copy link
Contributor

border-area content-box and border-area text seem reasonable.
border-area padding-box and border-area border-box should just behave like border-box I think.
text content-box and text padding-box would have their own behavior if there is text overflowing the content/padding box, but I can't image why someone would want this combination.
text border-box behaves like border-box, unless we change the definition of text.

@fantasai
Copy link
Collaborator

I have a preference for only supporting the reasonable values. The QA cost to checking invalid values are invalid is wayyy less than ensuring nonsensical values work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment