relative font-size of <sub> or <sup> and their descendants in IE

六月ゝ 毕业季﹏ 提交于 2019-11-28 11:15:39
Adam

It seems like the only "solution" to leave the font-size:100% reset-declaration in the stylesheet and still have acceptable sub-/superscripts is so far either to:

  • Use a different element for styling the sub-/superscripts, e.g. <span>. Definitely not a good idea in the light of semantics → eliminated.
  • Use an UserAgent-specific stylesheet, conditional comments at best (which is what I was worried about, because i didn't have to use them for IE ≥ 7, until now) and explictly restyle each descendant to compensate the "coefficient effect" → it's not worth it :-).
  • Leave it as it is so everybody can see IE has its own rules (ideally/naively this could force them to fix it in the next version) and use font-size:inherit to have at least the descendants of <sub> or <sup> be the same size by default in IE ≥ 8 → accepted.

solution #2, this will do the trick (sure it can be tuned up, but just the concept):

<!--[if IE]>
<style>
  sup *,sub * {font-size:120%; font-size:inherit;}
</style>
<![endif]-->

provided you don't strive for maximum performance (See the * selector performance issue).

I didn't test it but it works so far:

sup,
sub {
    font-size: inherit;   /* all browser */
    font-size: 120%\0/;   /* wie only */
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!