html - 手机浏览器绝对底层
问题描述
我在使用移动浏览器底部的特定偏移量正确定位文本时遇到问题。这里的CSS定位它。这显然可以在任何桌面浏览器上正确显示(包括低分辨率和更正的像素比),但在每个移动浏览器上都显示不正确。看起来移动屏幕测量考虑了潜在的菜单大小,但我不确定。如何解决?
position: absolute;
bottom: 0;
transform: translateY(-30px);
一个活生生的例子要复杂得多,但这是对问题的简单演示。在桌面上,文本完全适合黑线。在手机上,它向上移动了 3-4 px
* {
box-sizing: border-box;
}
html {
font-family: sans-serif;
scroll-snap-type: mandatory;
scroll-snap-points-y: repeat(100vh);
scroll-snap-type: y mandatory;
}
h2 {
position: absolute;
bottom: 10px;
text-align: center;
color: white;
width: 100%;
left: 0;
font-size: 50px;
clear: both;
}
section {
border-bottom: 1px solid white;
padding: 1rem;
height: 100vh;
scroll-snap-align: start;
text-align: center;
position: relative;
background: #EAB003 url('https://i.ibb.co/RTHZnxB/bgbg.png') no-repeat fixed bottom
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
</head>
<body>
<section>
<h2>Hello Kittie 1</h2>
</section>
</body></html>
解决方案
推荐阅读
- django-rest-framework - Django rest框架mongoengine使用默认值更新新字段
- node.js - 如何从 Excel 中的循环中添加多条记录?
- django - 如何在 Django 中使用 bulk_update 方法保存对象列表?
- python-2.7 - 等待另一个 python 进程继续
- android - TypeAdapter 序列化/反序列化模型类中的对象
- database - 如何解决flutter sqlite语法错误?
- llvm - LLVM Pass - 替换 GlobalVariable 的问题
- json - 在 React 中递归渲染嵌套数据,我想恢复这个文件 json 的“名称”
- redis - haproxy pod 保持 crashloopbackoff
- arrays - 将数组转换为哈希