Compounded relative font-sizes: a clean way to adopt the font-size of the child, not the parent element

谁都会走 提交于 2019-12-06 05:50:00

What you want can be achieved by using rem units.

rems are relative ems which base their calculations on the font-size declared on the body element.

Compounding issues simply disappear.

http://snook.ca/archives/html_and_css/font-size-with-rem is an excellent article to articulate this.

note: IE8 requires a px fallback, but this won't be an issue since you're already making use of a preprocessor.

EDIT: I've written a Sass mixin which outputs rems with their respective px fallbacks for most CSS properties: https://gist.github.com/larrybotha/4153104

I'll answer the same as my question, use Pixels!

A pixel is a relative unit, it's relative to the screen resolution, users can set their own desired minimum pixel size, and zoom zooms pixels. I'd venture that it is more difficult for a designer to approximate non pixel font-sizes at every perceivable resolution than it is to relax and let the browser tools take care of it?

It used to be that a font declared in pixels wouldn't resize in IE which was very annoying for some, not very accessible if a user deliberately chose to view on a lower resolution for instance for eyesight reasons - that's where the "em's were best for fonts" thing came from, but that was never true IE could be foiled using percentages instead which then offers the same problems ;).. I remember getting annoyed when the fad was for "teeny text", but then the joys of discovering CTRL+ in non-ie .. anyway now the pixel sized fonts will scale perfectly well, if you're building a fluid site you can build it with a mixture of em's for widths and pixels for font-sizes - if it looks OK at your resolution try zooming it, both up and down - you have to go pretty far up or down before it becomes illegible, and who's zooming it that far up/down except designers ;)

Have you considered adding a class to the headings that are in table cells? The extra level of specificity would override the effect of the cascading styles compounding each other, I think.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!