【问题标题】:Prevent bold font-weight from changing line-height防止粗体字重改变行高
【发布时间】:2013-07-06 10:35:43
【问题描述】:

这可能看起来很乏味,但我需要找出一种方法来确保站点的所有行都在基线网格上。问题是锚被设置为font-weight: bold,这在锚文本的顶部增加了似乎是 2px 的空间。有一个简单的 CSS 解决方案吗?

【问题讨论】:

  • 在 jsfiddle 中发布一些 HTML 和 CSS,以便我们有一些东西可以查看...谢谢!

标签: html css


【解决方案1】:

您应该考虑为所有网站使用 CSS 重置:http://meyerweb.com/eric/tools/css/reset/

例如,取自上面的链接:

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}

如有必要,您可以将font-weight: regular 添加到该列表中。

【讨论】:

  • 抱歉删除.. 这是一个好主意黑鸟,但它为我做的是设置一个{line-height: 0}
【解决方案2】:

最终为我工作的是以下 CSS:

a {line-height: 0}

【讨论】:

    【解决方案3】:

    为避免观察到的行为,一种可能的解决方案是将 line-height 设置为特定值。

    【讨论】:

      猜你喜欢
      • 2017-04-13
      • 1970-01-01
      • 2012-10-13
      • 1970-01-01
      • 2013-07-13
      • 1970-01-01
      • 2017-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多