<html>
<head>
<style>
img {
width: 200px;
height: 400px;
object-fit: cover;
border: 5px solid red;
}
</style>
</head>
<body>
<h1>Change object-position with JavaScript</h1>
<p>Click the "Try it" button to change the object-position of the image:</p>
<img src="paris.jpg" alt="Paris" id="myImg" width="400" height="300">
<br>
<button onclick="myFunction()">Try it</button>
<p>Note: The object-position and object-fit properties are not supported in Internet Explorer/Edge 15 or earlier.</p>
<script>
function myFunction() {
document.getElementById("myImg").style.objectPosition = "0 10%";
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/cssref/tryit.asp?filename=trycss3_js_object-position by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:01:20 GMT -->
</html>