Можно так. Но это костыль
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="Keywords" content="">
<meta name="description" content="">
<title>ГГ</title>
<style>
*{
margin:0;
padding:0;
outline: 0;
}
.container {
position: relative;
margin: 20px;
width: 1500px;
height: 1500px;
border: 1px solid red;
}
.inner {
margin: 50px;
width: 200px;
height: 200px;
border: 1px solid red;
}
</style>
</head>
<body>
<div class="container">
<div class="inner">Внутренний блок</div>
</div>
<script>
function Scroll(){
var inner = document.querySelector('.inner');
if ( typeof Scroll.x == 'undefined' ) {
Scroll.x = window.pageXOffset || document.documentElement.scrollLeft;
Scroll.y = window.pageYOffset || document.documentElement.scrollTop;
}
if (!((Scroll.x - window.pageXOffset == 0)&&(Scroll.y - window.pageYOffset== 0))) {
var diffX = Scroll.x - window.pageXOffset;
var diffY = Scroll.y - window.pageYOffset;
}
if (diffX != 0){
inner.style.position = 'relative';
inner.style.top = Scroll.y +'px';
inner.style.left = null;
}
if (diffY != 0){
inner.style.position = 'fixed';
inner.style.top = null;
inner.style.left =20 - Scroll.x + 'px';
}
Scroll.x = window.pageXOffset;
Scroll.y = window.pageYOffset;
}
window.onscroll = Scroll;
</script>
</body>
</html>