首页 > 解决方案 > 固定标题在移动浏览器上被截断

问题描述

我有一个具有 css 的移动设备的固定标头:

header {
position: fixed;
top: 0;
left: 0;
width: 40%;
height: 70px;
background: #191919;
z-index: 10;
-webkit-transform: translate3d(0,0,0);
padding-top: 10px;
}

这在大多数浏览器中都可以正常工作,但在三星浏览器中,状态栏会被剪切或隐藏,如下图所示,尤其是在滚动时

移动标题捕获

header {
  position: fixed;
  top: 0;
  left: 0;
  width: 40%;
  height: 70px;
  background: #191919;
  z-index: 10;
  -webkit-transform: translate3d(0, 0, 0);
  padding-top: 20px;
  width: 100%;
  color: white;
}

.content {
  background: red;
  position: relative;
  padding-top: 70px;
  width: 100%;
  height: 150vh;
}
<header class="myheader">My Header</header>

<div class="content">Some content</div>

标签: htmlcss

解决方案


这是一个简单的解决方案。我添加了 overflow: scroll to #main { overflow: scroll;},包含标题和下面内容的 div 容器,问题已解决。


推荐阅读