-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider switching to em
unit
#16
Comments
+1. A single class approach also works for that: .top-menu [class^="icono-"] {
font-size: 16px;
}
.sidebar [class^="icono-"] {
font-size: 24px;
} Not to mention media queries. |
@joaocunha Good points. Only thing I’d just caveat is that doing non-integer multiples of the base font size (whatever that ends up as in this This made me just think of a potentially interesting approach in which the base font size is set to |
@adamschwartz I don't think non-integer would cause any side effects as long as we're using The easiest way to convert is to use FROM: .icono-check {
width: 28px;
height: 28px;
margin: 3px 0 3px 6px;
transform: rotate(-45deg);
} TO: /* base value for all icons, comes as standard and can be overriden by cascade */
[class^="icono-"] {
font-size: 10px;
}
.icono-check {
width: 2.8em;
height: 2.8em;
margin: .3em 0 .3em .6em;
transform: rotate(-45deg);
} This would convert the units and everything would look exactly the same. The base font-size would ship with the lib, and would be overriden as required, like on the previously mentioned |
I might not have been clear but I was originally commenting on the
What I’m saying is |
It’s not easy to tell, but in your example, the Here’s a quick example which exhibits the issue more clearly: <style>
.icon {
font-size: 10px
}
.icon.icon-large {
font-size: 15px
}
.icon.icon-test {
height: 1em;
width: 0;
border-left: .3em solid red;
border-right: .6em solid blue
}
</style>
<div class="icon icon-test"></div>
<br>
<div class="icon icon-large icon-test"></div> In the small icon, the blue right border is twice the width of the left red border. In the large icon, the blue icon is 9/4ths larger, since in a border width, the browser rounds 4.5px to 4px. Depending on where the units are used, you’ll either get ratios off (like this example) or you’ll lose pixel-fitting (assuming the originally-sized set was already pixel-fitted). |
Ok, now I see what you mean. Can't think of any other solution other than abiding to safe base font-sizes. That would most likely require some tweaking on the icons as well. |
I'm very interested in this becoming a thing - it should be easy to use the icons at any scale desired, and |
Awesome work!
After looking at the way you handled icon sizes (which I thought was really clever, btw), I couldn’t help but wonder if you might benefit from employing the same strategy but with fractional
em
s instead ofpx
. For example, you could set the base font size to say16px
and then set@1 = .0625em
,@2 = .125em
, etc.The potential benefit of this is you could then have a
.icono-2x
class, for example, which would simply applyfont-size: 32px
and all of the icons would get twice as big. You would only have to add a single line of extra CSS to get sizes in2x
,4x
, etc. and the complexity of the.less
code wouldn’t have to change at all, afaict.I’ll note that I have made some icons like this before and have run into odd browser rounding issues. So this might be a concern. But I think it might be fine if you set a base font size for all icons in
px
and then useem
for thewidth
,height
,border-width
,::after
and::before
sizes, etc.I’d be happy to take a stab at a PR if you think this is something icono could benefit from.
The text was updated successfully, but these errors were encountered: