css - 调整页面垂直居中内容

标签 css vertical-alignment

我正在尝试构建类似于 this 的页面,当调整浏览器窗口大小时,内容保持垂直居中。

这是我到目前为止所得到的:

http://codepen.io/realph/pen/svuHI

我试图让 .marketing 元素保持垂直居中。虽然页脚贴在页面底部,但在调整浏览器窗口大小时也会向上移动。

感谢任何帮助。提前致谢。

最佳答案

将此添加到您的 .marketing CSS

position: absolute;
top: 50%;
margin-top: -50px; /* change this to half of the height of the element  */

关于css - 调整页面垂直居中内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21171685/

相关文章:

html - Internet Explorer 响应图像丢失纵横比

javascript - 根据动态值生成梯度步长,包括小数

html - 我如何垂直和水平居中所有这些元素?

css - 垂直对齐底部不起作用

css - 通过更改源或覆盖来修改 Bootstrap

html - 垂直重复图像边框

java - 如何在 vaadin 中设置网格单元格样式

css - 图像垂直对齐与 css - 奇怪

html - 将div与固定div垂直对齐作为父级?

html - css - 如果行数不同则 block 失控