вот код.
<html>
<head>
<style>
html, body {
height: 100%;
}
.main {
height: 100%;
}
.second_block {
height: 100%;
}
#download_present_img{
position: fixed;
z-index: 9999;
right: 15px;
bottom: 20px;
font-size: 50px;
font-style: normal;
margin-left: 20px;
width: 40px;
height: 40px;
background: red;
}
.footer_block {
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
position: relative;
height: 190px;
bottom: 0;
left: 0;
}
.footer {
color: #ffffff;
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 190px;
background: #000;
}
</style>
</head>
<body>
<div class="main"></div>
<div class='second_block'>
<div id="download_present_img"></div>
</div>
<div id="footer_stop" class="footer_block">
<div class="footer">
<div class="text_footer">
<p>footer</p>
</div>
</div>
</div>
<script>
function offset(a) {
for (var b = 0; a;) b += parseInt(a.offsetTop), a = a.offsetParent;
return b
}
var s = !0;
window.onload = function () {
var a = document.getElementById("download_present_img"),
b = offset(a),
f = window.getComputedStyle ? getComputedStyle(a, "") : a.currentStyle,
d = a.offsetHeight + parseInt(f.marginTop) || 0,
e = offset(document.getElementById("footer_stop"));
window.onscroll = window.resize = function () {
var c = window.pageYOffset || document.documentElement.scrollTop,
c = e - (c + d + b);
s != 0 < c && ((s = 0 < c) ? (a.style.top = b + "px", a.style.position = "fixed") :
(a.style.top = e - d + "px", a.style.position = "absolute"))
}
};
</script>
</body>
</html>