Safari中div的非常薄的意外边距

时间:2018-04-17 15:54:00

标签: html css

我正在尝试使用Safari解决此问题。我没有在任何地方找到解决方案。

enter image description here

输出应该是整个白页,并且在桌面浏览器(Firefox,Chrome)中正确呈现。但是在Safari(来自iPad和iPhone)中,我得到了这些恼人的薄边缘,让绿色背景显示在div的边缘。

奇怪的是,当我在Chrome devoloper的工具中设置“移动设备预览”时,我也获得了这些边距。

* {
  margin: 0;
  outline: none;
  border: none;
  padding: 0;
}

html,
body {
  width: 100vw;
  height: 100%;
  background-color: green;
}

.element1 {
  height: 50%;
  width: 100%;
  background-color: white;
}

.element2 {
  height: 30%;
  width: 100%;
  background-color: white;
}

.element3 {
  height: 20%;
  width: 100%;
  background-color: white;
}
<div class="element1">
</div>
<div class="element2">
</div>
<div class="element3">
</div>

是否可以改变这种行为?

1 个答案:

答案 0 :(得分:0)

html标签是否正确定义?

<!DOCTYPE html>

缩放级别?

<meta name="viewport" content="width=device-width, initial-scale=1">