<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
border: 1px solid black;
width: 300px;
height: 250px;
background: url('w3css.gif') no-repeat;
}
</style>
</head>
<body>
<h1>Change background-position-y with JavaScript</h1>
<p>Click the "Try it" button to set the background-position-y property of the DIV element to "center":</p>
<button onclick="myFunction()">Try it</button>
<div id="myDIV">
<h1>Hello</h1>
</div>
<script>
function myFunction() {
document.getElementById("myDIV").style.backgroundPositionY = "center";
}
</script>
</body>
</html>