Sử dụng backgroundAttachment với giá trị "fixed" để hình nền không cuộn theo nội dung.
Ví dụ
<!DOCTYPE html>
<html>
<body>
<button onclick="display()">Click để đặt hình nền cố định</button>
<p>Demo Text</p>... (nhiều dòng để cuộn)
<script>
function display() {
document.body.style.background = "url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg') no-repeat right top";
document.body.style.backgroundAttachment = "fixed";
}
</script>
</body>
</html>