html - 移动设备的背景图片不居中
问题描述
出于某种原因,从我的手机查看时我的背景图像没有保持居中,但是当使用 Chrome 开发工具中的切换设备工具栏从我的桌面浏览器查看移动屏幕尺寸时,它保持居中。
body { padding: 0; margin: 0; }
h1 {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 50px;
font-family: "PPWoodland-Bold";
color: #18454A;
animation: drop 1s linear;
padding: 1rem 0 0;
margin: 0;
}
#banner {
width: 100vw;
height: 100vh;
background: url("https://cdn.shopify.com/s/files/1/0099/7795/4368/files/banner-stripped.png?v=1633873595") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
@media (max-width: 749px) {
#banner h1 { font-size: 32px; }
}
<div id="banner-wrap">
<div id="banner">
<h1 id='banner-title'><span>Lorem Ipsum</span><span>dolor sit amet</span></h1>
</div>
</div>
解决方案
推荐阅读
- amazon-dynamodb - Dynamoose 聚集体 MAX
- python - 在python中使用kNN和决策树获得一个常数结果
- scope - 无法在 except 块中访问 y
- angular - 找不到模块“bootstrap/dist/js/bootstrap”的声明文件
- android - 需要在内置相机应用程序中显示自定义形状叠加
- r - Profvis 上的错误:没有可用的数据框
- azure - Azure CDN、终结点和 DNS 区域是否仅全局?
- ms-access - 如何重复我在访问报告的输入参数框中输入的内容?
- typo3 - bootstrap_package 的更新向导失败
- wordpress - 在电子邮件中添加自定义标签联系表 7