Let we have an element of fixed Height and width. We placed an large size's image in it. Then we can crop the image by css and centre the image vertically and horizontally both in element.
I’m giving an example:-
let we have an element. which’s width is 100px and height 100px and now we take an large image in the element.
HTML
<div>
<img src=“dummy-large-image” class=“dummy-image">
</div>
CSS
.dummy-image {
text-align: center;
transform:translateY(-50%);
-webkit-transform:translateY(-50%);
-moz-transform:translateY(-50%);
}
THANKS
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Balraj Singh
Balraj is a creative UI designer with experience and capabilities to build compelling UI designs for Web and Mobile Applications. Balraj likes playing tech Quiz and loves bike riding.