You have encountered collapsing margins.
heatmap
is positioned with respect to the nearest ancestor which has position
that is not static
. This is the body
element.
The first child of the body
has a margin-top
.
That margin collapses through the top of the body
and pushes the body element down away from the viewport edge.
You can see this by applying an outline to the body element.
body {
position: relative;
margin: 0;
padding: 0;
outline: solid pink 10px;
}
.section1 {
margin-top: 107px;
border: 1px solid green
}
.heatmap {
z-index: 2147483642;
top: 0px;
left: 0px;
position: absolute;
width: 1425px;
height: 1110px;
opacity: 0.7;
background: red
}
<div class="section1">something</div>
<div class="heatmap">hamara heatmap</div>
To avoid this, prevent the margins from collapsing. This is most easily done by using padding on the body instead of margin on the heatmap.
body {
position: relative;
margin: 0;
padding: 107px 0 0 0;
outline: solid pink 10px;
}
.section1 {
border: 1px solid green
}
.heatmap {
z-index: 2147483642;
top: 0px;
left: 0px;
position: absolute;
width: 1425px;
height: 1110px;
opacity: 0.7;
background: red
}
<div class="section1">something</div>
<div class="heatmap">hamara heatmap</div>