css - 垂直居中在 Firefox 中不起作用

标签 css firefox

我正在使用父容器将一个 div 垂直居中。

http://danacoleproducer.com

它适用于 Safari 和 Chrome,但不适用于 Firefox。我看了这篇文章:CSS vertical-align: middle not working但我宁愿不使用表格。

我的 CSS:

.wrapper {
    height: 100%;
    max-width: 420px;
}
.wrapper:before,
.container {
    display: inline-block;
    vertical-align: middle;
}
.wrapper:before {
    content: '';
    display: inline-block;
    width: 0;
    height: 100%;
    vertical-align: middle;
    margin-left: -0.25em;
}
.container {
    text-align: justify;
    font-size: 12px;
}

最佳答案

以下可能会成功 ;-)

.container {
position: relative;
top: 50%;
transform: translateY(-50%);
}

其中 .container 是您想要垂直居中的内容。

关于css - 垂直居中在 Firefox 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26726274/

相关文章:

javascript - 强制刷新 js/css/html 更改 webapp 上的缓存

php - 将透明背景颜色应用到特定表格[行][列]

html - 使用css的html列表背景颜色顶部的图像

javascript - 加载后如何在网站背景中绘制网格线?

jquery - jQuery 中的左边框宽度返回 NaN

css - HTML 5 下拉菜单

javascript - 如何从扩展中检测页面加载错误?

php - IE 10 和 Firefox 与 phpmyadmin 的问题

firefox - 创建一个新的 Firefox 附加组件 : XUL or Jetpack?

javascript - 使用 jquery 在 chrome 中的元素宽度