为什么我的下层div不在Android上居中,而在显示器上居中?

真菌类

我环顾四周,似乎无法找到解决问题的方法。

底部的两个div为何在Windows 8上以左右完美的一半被切开,但是在我的android s5上却没有居中?http://danny4help.com/

#grad4_left img {
    height: 100%;
    width: 100%;
    border-radius: 10px 0px 0px 10px;
}

#grad4_right {
    z-index: inherit;
    height: 700px;
    background-color: #F1EEF7;
    top: 705px;
    width: 50%;
    left: 50%;
    text-align: center;
    font-size: 80px;
    line-height: 40px;
    color: #4A4A4A;
}

.grad#grad4_left {
    z-index: inherit;
    height: 700px;
    background-color: black;
    top: 705px;
    right: 50%;
    color: #4A4A4A;
    width: 50%;
}

在此处输入图片说明

厄普西隆

You have several divs that have fixed widths in pixels, both above and below the incorrectly centered divs. These divs are wider than the body, so the viewport automatically expands to show the full width of those elements, making it seem as though your divs are incorrectly centered. Simply replace the pixel units of the width of the too wide divs with either percents of viewport units and you'll be good to go (e.g., .grad has a width of 1280px. Change that to 100vw). For a quick and dirty fix, add this block to the top:

* {
    max-width: 100vw;
  }

编辑:其他一些答案建议您不要在响应式布局中使用绝对定位。使用position: absolute实际上是OK,只要你使用的是相对单位(例如%emvw),而不是固定的单位(例如pxinpt)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用Bootstrap 4在小型显示器上的div中居中显示文本

为什么我的svg不在div容器内居中?

为什么我的 2 个按钮不在 Div 中居中?

Android ScaleAnimation不在屏幕上居中

为什么Filezilla不显示在我的任何显示器上?

为什么位置绝对按钮在较小的显示器上重叠了我的内容?

为什么我的Dell显示器上挂有USB电缆?

ProgressBar不在片段上居中

在div上居中视口,不在视口中div

为什么我的jQuery不在我创建的第二个div上添加显示?

谁能告诉我为什么此文本不在Android Studio中居中?

为什么我的限制 requestAnimationFrame 在我的 144hz 显示器上不能以 60FPS 运行?

尝试使div居中,以便当我切换显示器时它们保持相同大小

离子导航栏:标题不在Android设备上居中

我把醋放在显示器上

为什么这些按钮在 iPhone 上是矩形的,而在我的桌面浏览器上是方形的?

为什么我不能居中?

为什么我不能居中?

在远程X显示器上打开一个窗口(为什么“无法打开显示器”)?

为什么我的主窗口不能在屏幕上正确居中?

文字不在球拍中的邮件%上居中

组合框不在视觉上居中

AppCompat Snackbar不在平板电脑上居中

为什么框架不在Tkinter上显示

为什么在同一4k显示器上显示的winform不同

为什么我的div没有水平居中?

为什么我不能将这个简单的 div 居中?

为什么我的Div偏向右侧而不是居中?

不在div中居中