I'm thinking about creating a script that allows me to create sort of dynamic classes in a style tag. i.e.:
HTML:
<p class="padding-top-24">test</p>
SCRIPT:
- create a
<style>tag; - check if
.padding-top-24already exists in this tag, if not, create the class and use her in the element;
But is it worth? I mean, I know that I could simply use style="padding-top: 24px", but what if I want something more specific like a class that the element only has padding-top: 24px when the users is on a small screen?
Again, I could use @media (max-width: 600px) { .pading-top-24px { padding-top: 24px } }, but I would need to create a @media every time that I want something to have differents properties in specific moments.
Wouldn't it be better if I created a script that do it for me every time that I simply use a class? Using specific sizes for creating the medias. Something like:
HTML:
<p class="s-font-size-20 m-font-size-24">Hello</p>
SCRIPT:
- check the class and use/create the media that it should be part of (in this case, "s" stands for "small" or "<600px" and "m" stands for "medium" or "<992px").
- add a listener to the media and apply that class if the screen size corresponds.
Does it makes sense? Would it be usefull? Does it already exists?