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-overflow] New expand value for overflow. #7839

Open
votemike opened this issue Oct 6, 2022 · 3 comments
Open

[css-overflow] New expand value for overflow. #7839

votemike opened this issue Oct 6, 2022 · 3 comments

Comments

@votemike
Copy link

votemike commented Oct 6, 2022

I would like to propose a CSS way to expand an element that has overflow: hidden;.

My initial thought is that a new value for overflow of expand could be used in conjunction with either min-height, height or max-height properties.
Alternatively, the entire logic for the expandable element could sit within the overflow property. E.G. overflow: expand 200px 600px scroll; for using the expand option, the maximum height of the collapsed element, the maximum height of the expanded element and the overflow option to use if the content will still overflow the element after being expanded.

If an element reaches the point where it will overflow, the browser could add a marker similar to the details/summary marker that will toggle the expanded or collapsed states. This marker could then be styled or targeted by javascript. Elements with overflow could then also be targeted with :has(::marker).

It would be great if the collapsed size could be specified by either a character count or a height. And that there were a range of ways to show that there was more text once expanded (ellipsis, fade, peek-on-hover animation etc....).

Attached in an example of the sort of thing I'd like to be able to create in pure CSS.

Screenshot 2022-10-06 at 12 12 37

@markwylde
Copy link

markwylde commented Oct 6, 2022

If given the following example (playground):

image

I am using JavaScript to "know" if we need to show that checkbox, based on if the content has been overflowed.

I was thinking maybe a pseudo class of :overflowed could work, so no JavaScript would be required?

So the css from my example above:

eg-collapse:has(eg-collapse-content:not(.overflowed)) eg-collapse-controlbox {
  display: initial;
}

Would replace the .overflowed with :overflowed as below:

eg-collapse:has(eg-collapse-content:not(:overflowed)) eg-collapse-controlbox {
  display: initial;
}

@Loirooriol
Copy link
Contributor

Elements with overflow could then also be targeted with :has(::marker)

I was thinking maybe a pseudo class of :overflowed could work

That's a no-go, see #2011

@votemike
Copy link
Author

votemike commented Oct 6, 2022

OK, that selector is no good. Or the idea is no good?
Do you think the proposal of the new value has legs?

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

No branches or pull requests

4 participants