【发布时间】:2010-05-22 20:38:09
【问题描述】:
当我在 CSS 中更改字体的大小时,如何使无论字体大小(从 12 像素到 200 像素),文本的“大写高度”(图片)始终“可视化” ' 顶部有 10px 的内边距?
否则我所做的是每次更改字体大小时,我都必须返回并重新定位顶部/边距顶部等。
这是我所拥有的:
CSS:
#header .statement {
position: relative;
background: white;
padding-top: 10px;
display: inline;
float: left;
margin-left: 0;
margin-right: 0;
width: 960px;
}
#header .statement h3 {
position: relative;
font-size: 160px;
letter-spacing: -10px;
font-weight: bold;
color: #141414;
font-family: Helvetica, sans-serif;
text-align: center;
}
HTML 示例:
<div id='header'>
<div class='intro'>
Stuff before the statement
</div>
<div class='statement'>
<h3>
<p>A Statement</p>
</h3>
<div class='large_spacer'></div>
</div>
<div class='clearfix'></div>
</div>
这就是line-height: 0 的样子:
alt text http://ilove4d.com/ex/css-typography.png
这是line-height: 1:
alt text http://ilove4d.com/ex/css-typography-2.png
如果我将 font-size 从 160 像素更改为 20 像素,空白区域会按比例变小...我该如何解决?
注意:它会添加 20px 额外的空白,即使 margin:0;padding:0;...
【问题讨论】:
-
你试过设置包含元素的 padding-top 吗?
-
看来我必须设置
line-height: 0.8才能设置正确的基数。然后我可以使用填充...这是为什么呢? -
可能是添加了您所说的 20px,因为您在
中添加了一个
标签。如果您没有重置
标签上的边距和行高,就会发生这种情况。更好的是,只需去掉
标签。
标签: css typography