-
Notifications
You must be signed in to change notification settings - Fork 24
Use case: Responsive Typography #71
Comments
Is this a use-case for container-based units for sizing (like The exact thing you describe here: "scalable font-sizes trapped inside a modal with a |
@tomhodgins Yes and no. One thing I didn't go into actually makes this even more complex. Which is - in our case, something like a heading might have a certain amount of "visual affordance" but actually be restricted in its max-length by restricting the amount of columns it was actually in. In other words, say we have a Hero space - a big space at the top of the page with a giant background image. In that space, we want a giant header. So, visually, it "looks" right because there's so much negative space around the header. However, we don't actually want the heading to span the full width of the hero because we want to keep our line length reasonable for readability. So we don't want to assign container-based units for font-size. Instead the most ideal would be something like: h1 {
font-size: 32px;
}
.container:query(width > 600px) h1 {
font-size: 48px;
}
.hero:query(width > 1000px) h1 {
font-size: 60px;
} Essentially, we need to target our This would not work: h1 {
font-size: 100ew;
} What our I don't actually think container-based units are the right direction, because of the unique challenges of CSS Grid, but that's just me. |
This is real good, and I think it’s good because it’s a pretty common pattern. The folks at Filament Group had a write-up that comes immediately to mind. (They were dealing with a module shuttling between the main content well and a sidebar, not a module conditionally appearing in a modal overlay, but: tomayto, tomahto.) @matthew-dean, do you think this is distinct enough from #72 to be written up as a use case? If so, would you be willing to take point on drafting it? (Apologies for missing this when you first opened it; I appreciate you nudging us in Slack!) |
So, at work we had the following use case that led us to use JS-driven container queries:
@media
queries.(Incidentally, this is where I pause and say this is a demonstration that no CSS author has ever needed
@media
queries, and the only valid use case is and always has been container queries, but I digress.)The text was updated successfully, but these errors were encountered: