开发者

CSS font-size increment - proportional?

I have several elements with already set fonts - like

  <div style="font-size: 10px">
    some text
    </div>

    <div style="font-size: 20p">
    some text
    </div>

I want to increment the font size proprtionally, eg

<div style="font-size: 15px">
...................开发者_如何学C.......
<div style="font-size: 30px">

is that possible? div {font-size: whatever} simply overwrites the values


Your question is unclear:

<div id="fred" style="font-size: 10px">hello</div>
<div id="walt" style="font-size: 20px">there</dev>

States absolute sizes which are absolute and there isn't anything that could alter those absolute measures except changing the literals. This is why many texts recommend establishing a body font and sizing relative to that:

<body style"font-size: 10px">
  <div id="joan", style="font-size: 100%">hello</div>
  <div id="mary", style="font-size: 200%">world</div>
</body>

Would make "joan" 10px and "mary" 20px. Changing the body size to 15px would make "joan" 15px and "mary" 30px.That forms an attribute "cascade". Of course all this should be done in a style block rather than in the div attributes, but it would make this answer less direct.


Using relative units in font sizes will scale them relative to the font size of the parent element, but the cascade doesn't provide a way to say "relative to the font size that this overrides" (and it would usually turn into a complete mess if there was a way).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜