html - 为什么这些跨度的高度呈现不同?

标签 html css safari

我注意到 span 的高度根据所选的字体系列和父对象呈现不同。例如,对于字体大小:14px 和字体系列:Helvetica 或 Arial,跨度在 button 中的高度为 17px,但在 a 中的高度为 16px。对于 Verdana,两个跨度的高度都是 17px。

这是一个例子:

div.arial {
  font-family: Arial;
}
div.helvetica {
  font-family: Helvetica;
}
div.verdana {	
  font-family: Verdana;
}
button,
a  {
  text-transform: uppercase;
  font-size: 14px;
  text-decoration: none;
}
button {
  background: none;
  margin: 0;
  padding: 0;
  border: none;
}
<div class="arial">
  <button>
    <span>arial button 17px</span>
  </button>
  <a href="#">
    <span>arial anchor 16px?</span>
  </a>
</div>
<div class="helvetica">
  <button>
    <span>helvetica button 17px</span>
  </button>
  <a href="#">
    <span>helvetica anchor 16px?</span>
  </a>
</div>
<div class="verdana">
  <button>
    <span>verdana button 17px</span>
  </button>
  <a href="#">
    <span>verdana anchor 17px</span>
  </a>
</div>

为什么会这样?有一些解决方法吗?

最佳答案

尝试在 buttona 标签上设置 display: inline-block 和高度。

关于html - 为什么这些跨度的高度呈现不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52765617/

相关文章:

html - 如何在ionic 3中使脚覆盖页面的整个宽度

html - 如何从按钮的左侧和右侧删除可点击区域?

javascript - 如何制作单个子 div 滚动条?

ios - 如何阻止来自 iOS 主屏幕 PWA 的第 3 方登录流程在 Safari 中打开?

html - 左切换菜单,就像在 facebook 中一样

html - 2 个 CSS 背景和封面

css - 使用 CSS 定位图像

javascript - onClick 不适用于移动设备(触摸)

android - 继续为 apple-touch-icon.png 获取 404

javascript - 使用 AngularJS 在 HTML 中显示 Unicode?