html - 如何使文本垂直居中?

标签 html css text-align

如何使文本 测试文本 垂直居中?见here

我想让文本和边框底部之间的距离等于文本和边框顶部之间的距离。 `

最佳答案

对于单行文本,使用等于高度(或四舍五入为偶数)的line-height

#a {
  display: inline-block;
  padding-right: 20px;
  padding-left: 15px;
  font-family: 'Roboto';
  font-size: 12px;
  font-weight: bold;
  font-stretch: condensed;
  COLOR: white;
  border-left: 10px solid transparent;
  border-bottom: 25px solid;
  border-bottom-color: #FF3300;
  height: 0;
  line-height: 26px;
  top: 50%;
}
<span id="a">TEST TEXT</span>

关于html - 如何使文本垂直居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27982686/

相关文章:

css - OVH 服务器中没有 CSS 内容的 Symfony 2 应用程序?

css - 如何在 WordPress 的某些页面上隐藏类?

css - 使用 Compass 函数而不使用 Compass 来编译样式表

html - 如何对齐图像旁边的标题和副标题?

button - Google+ 游戏按钮

javascript - jQuery:CSS 显示 block 不工作

html - 放大时 Div 不断溢出到其他元素上

javascript - 更改图像属性时如何使用 jquery 获得平滑效果?

java - Flying-saucer 生成的 PDF 文本不合理

css - 使用 text-align justify/text-justify and right 时的奇怪行为