Here's a neat little trick:
You can use the clamp() CSS function to make font-size responsive and fluid!
It works by "clamping", or restricting...
For further actions, you may consider blocking this person and/or reporting abuse
For older browsers, we could do something like:
This should at least work on older Safari. As for IE, well, it doesn't support
@supports
. :|Great suggestion, Darshak! I wish I could pin comments
Hey Vitor, you could edit the post adding this suggestion. Makes sense to increase support with little effort.
Well, it's more a matter of graceful degradation than support increase but your idea is great, I'll do it right now!
Awesome! Thank you for the article and the examples. Much appreciated!
Reading this reminded me of a Github project I saw a couple months ago that allows you to clamp "a line" of text so that the same number of words stay on it regardless of font size.
github.com/tvanc/lineclamp
Dang, that's awesome.
It's wild seeing how CSS is evolving.
Yeah! My first experiences with CSS were full of floats and clearfixes so I'm glad to have modern tools like CSS functions, custom properties and Flexbox now 🙂
Where it really shines is if you do something like
so that you can modify the speed, and domain, of the responsive scaling.
Damn, this is going to forever change the way I style my content.
This is genius, never heard of clamp before now.
Thanks!
Hmmm, can this be pollyfilled in anyway?
EDIT: found a good solution to use it in older browsers via sass bronco.co.uk/our-ideas/creating-a-...
The tricky part is that the browser also needs to support the
vw
. Which our old friend IE also doesn't and never will. :(I believe the only way to polyfill it would be by using something with JS, like fittextjs.com/
Thank you so much for sharing this
This will really improve my responsive designing skills
It's crazy how powerful these functions get when you mix them in with modern modules, too, like grid.
Damn! Some time ago I needed to implement this kind of thing. I only found JS libraries that did not meet my expectations. I wonder how would it have been with this feature :)
I believe you're talking about fittextjs.com, right? I also had to do something similar in the past and got super bummed out with the fact that I had to use JS for such a small thing
Nice article Vitor!
Must really start using this!
Thanks, Chris. You should, yeah! It is so simple and works so well that makes you wonder why we didn't have it before, haha
Woo, that's cool! Surely going to try this on my next project.
looks nice, but i won't use if because of the low support. Maybe in a few years
Thank you !!!! <3
Happy to help! 😄
Amazing, few days ago i wrote a web page using css and html, had to add more then 6 media queries because the button and h1 positioned absolute to background pic were going down on smaller viewports 👐