不覆盖Html字体大小

时间:2016-01-17 15:00:54

标签: html css font-size

我需要添加一些样式来影响整个html文本大小百分比。使用以下内容,我只能使用默认字体大小更改文本,而不能使用固定文本大小更改文本。

我的HTML:

<style type="text/css">body{font-size:300%;}</style>
<body>
The <font style="color:#ff0000">company has been a </font>long way<strike> in the most part</strike> of a good <u>idea tying </u>I was <b>wondering</b> if you <font style="font-size:20px">are not the</font> intended <font style="background-color:#00ff00">recipient</font> of the <i>most</i> important <font style="color:#ffbf00">thing</font> 
</body>

Sentense“不是”并没有受到影响,因为它给出了它自己的字体大小20px。想要的是乘以3(第一行中的300%)。

1 个答案:

答案 0 :(得分:1)

CSS和内联调用完全按预期工作。

body上的CSS被内联的CSS覆盖,优先于它。

300%是一个值,而不是乘数。

&#13;
&#13;
body {
  font-size: 300%;
}
&#13;
The <font style="color:#ff0000">company has been a </font>long way<strike> in the most part</strike> of a good <u>idea tying </u>I was <b>wondering</b> if you 
<font style="font-size:20px">are not the</font> 
intended <font style="background-color:#00ff00">recipient</font> of the <i>most</i> important <font style="color:#ffbf00">thing</font> 
&#13;
&#13;
&#13;

另一种方法是使用CSS3 calc()函数,您可以在其中指定希望值20px乘以3。

&#13;
&#13;
body {
  font-size: 300%;
}
&#13;
The <font style="color:#ff0000">company has been a </font>long way<strike> in the most part</strike> of a good <u>idea tying </u>I was <b>wondering</b> if you 
<font style="font-size: calc(20px * 3)">are not the</font> 
intended <font style="background-color:#00ff00">recipient</font> of the <i>most</i> important <font style="color:#ffbf00">thing</font> 
&#13;
&#13;
&#13;

相关问题