gornycreative Posted October 24, 2023 Share Posted October 24, 2023 Hello friends, I was playing around with the clamp techniques used to provide progressive font sizing, and it has replaced flowtype.js in most projects. But one of the things that I really missed was the ability to scale based on container width - rather than full viewpoint width. I was also interested in trying to replace fittext.js and learned a very useful technique with reasonable browser support: https://codepen.io/solonmg/pen/ZEwGEay instead of using vw units, you can apply: container-type: size; container-type: inline-size; And then by dividing the character count of a line by 100 and applying the outcome to use cqw units instead of vw units, you get the same scaling type features. If you are trying to get that optimal character/word line length in a given column, this will certainly help! The same clamping limits that already exist based on viewport widths work for containers. I don't know if it makes sense to have separate clamping settings for display text (like headings) and body text, but this is just something I have been playing around with. 4 Link to comment Share on other sites More sharing options...
szabesz Posted October 25, 2023 Share Posted October 25, 2023 Promising technique indeed, thanks for posting about it! I will explore it when starting my next project. Link to comment Share on other sites More sharing options...
bernhard Posted October 25, 2023 Share Posted October 25, 2023 I'm aware of container queries being something coming in the future but I thought it's not there yet or at least not well enough supported to be used just now. Let me know if I'm wrong and I'm happy to add support for it if that's possible. I think rfGrow() is a great helper and I'm happy that it's useful for you as well ? Link to comment Share on other sites More sharing options...
gornycreative Posted October 25, 2023 Author Share Posted October 25, 2023 Despite being a working draft feature, support is at around 88% so it isn't full but looking at the browser compatibility and the browser support I already need I figured it was okay for my purposes. https://caniuse.com/css-container-query-units For those who aren't yet comfortable, it's probably still worth earmarking. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now