html - Chrome 移动浏览器中的文本垂直对齐错误

标签 html css google-chrome mobile vertical-alignment

我有一个固定高度的 div,其中包含一些文本。行高 = div 的高度。问题:在 Chrome Mobile 中,文本无法完全垂直居中。在 Firefox Mobile 中一切正常。请注意,我使用的是标准 Verdana 字体。

我发现其他一些网站也遇到同样的问题。

我该如何解决这个问题,有什么建议吗?

提前致谢!

最佳答案

将以下 flex CSS 样式属性添加到您的特定 div 容器中,应该没问题。

.cells-block {
  font-family: Verdana;
  width:300px;
  height: 100px;
  background: red;
  display: flex;
  align-items: center;
  /* vertically   */
  justify-content: center;
  /* horisontally */
  text-align: center;
  /* addition: for text's lines */
}
<div class="cells-block">
  This is some text<br>Randomrandom stuff
</div>

关于html - Chrome 移动浏览器中的文本垂直对齐错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47762621/

相关文章:

php - Yii2 两个 submitButtons 去错 URL

javascript - 从使用 CodeMirror 创建的内联代码中删除填充

css - 缺少 Chrome 动画按钮

css - Chrome 不打印?

javascript - 如何重定向到 chrome-devtools ://protocol?

在表单中调用时的 Javascript 函数 'is not a function'

javascript - 警报适用于条件,但按下 “OK” 时会重定向到其他页面,并且不允许用户更改输入

html - 如何使用 css 创建滚动内容?

html - Bootstrap 3 - 居中菜单栏问题

forms - 在 OSX 上制作像邮件应用程序这样的输入字段