<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
img{
width: 200px;
height: 200px;
border: 1px solid black;
background-color: #fff;
margin-right: 1em;
object-fit: none;
object-position: left bottom;
}
button{
display: block;
}
</style>
</head>
<body>
<h1>CSS object-fit Property</h1>
<img src="apple.png">
<button onclick="myFunction()">Click Me</button>
<script>
var x = document.getElementsByTagName("img")[0];
function myFunction(){
x.style.objectPosition = "50% 50%";
}
</script>
<p><strong>Note</strong>: Click on the button to center the image.</p> </body>
</html>