我在WordPress上使用Visual Composer创建的这个站点(http://dev-500startups.pantheonsite.io/)需要在全屏div中水平和垂直居中的元素。
所以我使用了下面的flexbox CSS代码:
#home-header {
height: 100vh;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: space-between;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}我将该ID应用于头文件的div容器。#home-header容器内的div和元素不会应用任何其他与flexbox相关的属性。
它在台式机和平板电脑上运行良好。但是当我在纵向模式下(使用智能手机和模拟器)使用手机查看时,整个#home-header分区宽度总是溢出到右侧,你可以在这里看到:

这是使用Chrome Inspector。当我在手机上测试时,任何其他模拟器也会给出相同的结果和相同的问题。
如何让元素在较小屏幕上垂直居中,就像在较大屏幕上一样?
发布于 2017-02-17 21:59:09
将css替换为on,一切都能正常工作https://yadi.sk/d/ZVvzgxD23ED7BE
@media only screen and (max-width: 1000px)
responsive.min.css?ver=4.7.2:1
.header_inner_left, footer.uncover, header {
position: absolute !important;
width: 100%;
left: 0!important;
margin-bottom: 0;
}设置了标头'position: relative‘
https://stackoverflow.com/questions/42299290
复制相似问题