Comments (8)
Why size it in px at all? Why not percent, rem, or vw? The whole layout should be built on one principle or the other: fluid, or not.
I think the main idea is to prevent the text from stretching over wider screens making the text less readable.
I do understand that. If I were using a version of rfs that was mobile-first, I would probably specify my minimum font sizes using the Modular Scale library and then let rfs scale it up - rather than specifying a lot of rem sizes with decimals. That way you keep the ease of use factor and the size relations without having to use a bunch of small decimal numbers.
You can usepx
if you like, rem-sizes with a lot of decimals are not needed.
If you really want to stick with the mobile-first approach, I don't think RFS-technique will be suitable for you. It's just not designed like that. However, feel free the fork RFS or make something from scratch that's more like what you want.
Anyway, thanks for taking your time to figure out how RFS works and for the given feedback. @garrettw.
from rfs.
Hi @garrettw,
The main reason it wasn't designed mobile first is that browsers without vw
-unit support will correctly render there font-size.
If we use the mobile-first approach, we get this:
SCSS:
.title {
@include rfs(62);
}
CSS:
.title {
font-size: calc(23.6px + 3.2vw);
}
@media (min-width: 1200px) {
.title {
font-size: 62px;
}
}
For older browsers with a screen-width smaller as 1200px
the font-size will not be set.
However it might be interesting to add an option like $rfs-mobile-first
(default value: false) which switches to mobile first rendering?
from rfs.
@garrettw, I just added an option for mobile-first rendering, you can enable it by setting $rfs-mobile-first
true.
from rfs.
The article I linked above does it in a slightly different way. Thoughts?
.title {
font-size: 12px; /* base, mobile-first size */
}
@media (min-width: 400px) {
.title {
/* scaling size for viewports between 400px-800px */
font-size: calc( 12px + (24 - 12) * ( (100vw - 400px) / ( 800 - 400) ));
}
}
@media (min-width: 800px) {
.title {
font-size: 24px; /* largest size for widest viewports */
}
}
from rfs.
The purpose of RFS is to make font-resizing as easy as possible, you only need one font-size, resizing is done automatically.
For the method you mention, you will need a minimum and maximum font-size for each element where you want to set the font-size for. Aside from that, you will need to make sure you never cross-size texts (for example a text with a minimum of 14px and a maximum of 18px and an other text with a minimum of 15px and maximum of 17px).
from rfs.
True, you would have to know the min and max for each element. But what do you mean about cross-sizing texts? I don't understand the issue.
I understand that your mixin is focused on ease-of-use with only one parameter. In that case, it might make more sense to me to specify only the smallest font size in the parameter, and then scale up infinitely, based on some $rfs-factor
- because there is a practical limit to how small screens can get, but not much limit on how large they can get.
Do you think that could be at least as user-friendly as your way (if not more so)?
from rfs.
If you have a project where a lot of font-sizes are used, you need to remember which minimum/maximum pairs you have combined. If you have a text element with a font size of 14px on mobile and 18px on desktop and you have another element which has a font-size of 15px on mobile, you need to remember to use at least a font-size of 19px on desktop so that the importance of the text-elements remain in relation with each other. If that's not totally clear, don't mind, my point was that RFS is a bit easier to use because it only has one parameter.
I'm starting to understand where you want to go with the mobile-first approach. However, I do think there really is a need for a maximum font-size and not the minimum font-size.
For example, let's take Github. It has a container-width of 980px, if the sizes would scale up infinitely, I would definitely have a problem with bigger titles on my 2560px wide screen.
If you're used to work as a mobile-first developer RFS would indeed feel a bit strange, because it actually works the other way around. However, you need to see the value that is passed to the mixin more as a number that indicates the font-size, rather than an exact font-size. When I was working with RFS for mobile devices, I never know exact how big the font-size of an element was, but I did know what value it is. (this was by far the most vague explanation I gave on Github, but I hope you somehow know what I mean)
from rfs.
If you have a text element with a font size of 14px on mobile and 18px on desktop and you have another element which has a font-size of 15px on mobile, you need to remember to use at least a font-size of 19px on desktop so that the importance of the text-elements remain in relation with each other.
Ah ok, that is clear now. The relation between the sizes is what you were talking about. That makes sense.
For example, let's take Github. It has a container-width of 980px, if the sizes would scale up infinitely, I would definitely have a problem with bigger titles on my 2560px wide screen.
That certainly would be a problem, but the cause is the fixed px-sized container width. Why size it in px at all? Why not percent, rem, or vw? The whole layout should be built on one principle or the other: fluid, or not.
However, you need to see the value that is passed to the mixin more as a number that indicates the font-size, rather than an exact font-size.
I do understand that. If I were using a version of rfs that was mobile-first, I would probably specify my minimum font sizes using the Modular Scale library and then let rfs scale it up - rather than specifying a lot of rem sizes with decimals. That way you keep the ease of use factor and the size relations without having to use a bunch of small decimal numbers.
from rfs.
Related Issues (20)
- Error while running less - Potentially unhandled rejection [2] Could not parse call arguments or missing ')' on line 120 HOT 5
- Error with custom values HOT 1
- rfs() doens't work inside calc()
- PostCSS 8 compatibility HOT 2
- Strange values generated in Bootstrap 4.6 HOT 1
- Unclear doc concerning rfs-base-value or bug
- Use Sass Modules (dart-sass) HOT 18
- RFS + Less + css variables warning HOT 3
- Is RFS installed and enabled as part of Bootstrap 5? HOT 5
- Variation in size range seems too small HOT 1
- Migrate to postcss 8.x HOT 1
- rfs not working with $variable list ? HOT 1
- Minimum font size. HOT 2
- Feature Request - add overloads for shorthand mixins HOT 2
- rem and px have incompatible units in rfs-breakpoint HOT 2
- $rfs-base-value with rem breaks
- How to it this with tailwind ? HOT 4
- Sass ABS deprecation warning HOT 2
- using rfs() in SCSS with PostCSS syntax doesnt work HOT 1
- How to use it with react ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rfs.