Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> CSS

Thuộc tính object-position trong CSS


Thuộc tính object-position dùng để chỉ định cách định vị hình ảnh hoặc video bên trong hộp (box) của nó.

Ví dụ

<!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>

Kết quả

Thuộc tính object-position trong CSS