Observe the image below showcasing Paris, with dimensions of 400×300 pixels.
Subsequently, we apply object-fit: cover; to maintain the aspect ratio and completely fill the specified dimension. Nonetheless, the image will be trimmed or clipped to fit accordingly.
Example
img { width: 200px; height: 300px; object-fit: cover; } |
We’ll utilize the object-position property to adjust the image positioning, ensuring that the iconic old building is centered within the frame.
Example
img { width: 200px; height: 300px; object-fit: cover; object-position: 80% 100%; } |
In this instance, we’ll employ the object-position property to center the image, specifically positioning the renowned Eiffel Tower at the center.
Example
img { |