-
Notifications
You must be signed in to change notification settings - Fork 719
[css-values-5] [css-overflow-4]How does line-clamp
transition from
to auto
or none
?
#10502
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
Comments
I don't know too much about Things get more complicated when you consider that the number of lines that That said, I'm not familiar enough with transitions to know what the right behavior would be here. |
Thinking about this again, I wonder what the use case would be to transition from clamping by a number of lines to clamping by a height. Usually .item {
transition: height 3s;
interpolate-size: allow-keywords;
overflow: hidden;
}
.item.collapsed {
line-clamp: auto;
height: 4lh;
} Screencast.from.2024-10-22.11-41-28.mp4Rather than the lines appearing or disappearing into the hidden overflow, you could also set .item {
line-clamp: auto;
transition: height 3s;
interpolate-size: allow-keywords;
}
.item.collapsed {
height: 4lh;
} Screencast.from.2024-10-22.11-43-13.mp4But maybe there are other use cases for transitioning between a number and |
Looks good if it fixes the problem. |
There is also a scenario where an internal element contains data:text/html;charset=UTF-8,>
<style>
.item {
border: 1px solid green;
width: 300px;
height: 4lh;
line-clamp: auto;
font-size: 16px;
line-height: 1.5;
}
p {
margin: 20px 0;
}
style>
<div class="item">
<p>
It allows limiting the contents of a block container to the specified number of lines; remaining content is fragmented away and neither rendered nor measured. Optionally, it also allows inserting content into the last line box to indicate the continuity of truncated/interrupted content.
p>
div> |
Can we have line-clamp add a unit like lh (e.g. |
I don't think that's possible. There's questions like what does But more fundamentally, for a
Sorry to disappoint, but after looking a lot more into how |
Right, this definitely doesn't fall out of any existing behavior; if we wanted it, we'd have to define some brand new behavior for it. But as noted, it would be expensive. Since the obvious use-cases (transitioning the height between auto and a fixed size, and using |
The examples in #10502 (comment) rely on the fact that the text is plain and unstyled, and that there's no margin/padding/border disrupting things. If they were, we couldn't use a However, solving that seems hard. In a way, we'd need a value ( |
Uh oh!
There was an error while loading. Please reload this page.
@andreubotella The current implementation of
line-clamp
in Chrome addsauto
values, and the use case here is very much like theheight: 0
toauto
scenario.Will the
interpolate-size
property added a while ago work in this scenario?Demo: https://codepen.io/yisi/pen/rNgojEx
Explainers: https://github.com/Igalia/explainers/blob/main/css/line-clamp/README.md
cc @frivoal @tabatkins @dbaron @flackr
The text was updated successfully, but these errors were encountered: