Computer >> Computer tutorials >  >> Programming >> CSS

object-position Property in CSS


The object-position property is used to specify whether how we should position image or video inside its own box.

Example

<!DOCTYPE html>
<html>
<head>
<style>
img.demo {
   width: 200px;
   height: 200px;
   object-fit: none;
   object-position: 10px 20%;
   border: 2px dashed yellow;
}
</style>
</head>
<body>
<h2>Demo Heading</h2>
<img class="demo" src="https://www.tutorialspoint.com/memcached/images/memcached-mini-logo.jpg" alt="Memcached" width="400" height="250">
<h2>Memcached Tutorial</h2>
<img src="https://www.tutorialspoint.com/memcached/images/memcached-mini-logo.jpg" alt="Memcached" width="300" height="250">
</body>
</html>

Output

object-position Property in CSS