Html 如何在css中更改标题大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13241242/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change header size in css
提问by Stumbler
I am racking my brains on this one but I can't seem to find a solution.
我正在为此绞尽脑汁,但似乎找不到解决方案。
From a semantic point of view I want to use a h2 header - but from a visual pov I want it to look exactly like a h5 header.
从语义的角度来看,我想使用 h2 标头 - 但从视觉 pov 我希望它看起来与 h5 标头完全一样。
However, css is behaving oddly in relation to this, and seems to be treating the header text as normal text for formatting. So font-size:60%;
is coming across as 60% the size of normaltext - which is absolutely tiny! I've tried messing around with other aspects (like height), but to no avail. All stylistic properties relating to the header seem to disappear once you apply css to the font...
但是,css 与此相关的行为很奇怪,并且似乎将标题文本视为用于格式化的普通文本。所以font-size:60%;
它的大小是普通文本的60% - 这绝对是很小的!我试过搞乱其他方面(比如身高),但无济于事。一旦将 css 应用于字体,与标题相关的所有样式属性似乎都消失了...
回答by Abdul Malik
use px instead of percentage for example
h2{font-size:14px;
height:50px;}
例如使用 px 而不是百分比
h2{font-size:14px;
height:50px;}
回答by user1800957
if you are going to use % definitions for CSS rules Use the html tag fix for font rendering.
如果您打算对 CSS 规则使用 % 定义,请使用 html 标记修复进行字体渲染。
Next include the body tag which defines all the base font information for the document.
接下来包括定义文档所有基本字体信息的 body 标签。
The rest should work as desired.
其余的应该按需要工作。
/*css*/
html {font-size: 100.01%;}
body {font:italic bold 16px/30px Georgia, serif;}
h2 {font-size: 60%; line-height:60%;}
?
?
<!--HMTL-->
<!DOCTYPE html>
<html>
<body>
<div>blah</div>
<h2>header</h2>
<div>blah<br>blah</div>
</body>
</html>
see Example
见示例