html – CSS Display an Image Resized and Cropped – Stack Overflow
Posted by jpluimers on 2021/08/25
[WayBack] html – CSS Display an Image Resized and Cropped – Stack Overflow (thanks [WayBack] roborourke!); see full answer link for runnable snippet and HTML (the WordPress editor keeps fucking up preformatted code blocks with html or XML in it).
You could use a combination of both methods eg.
.crop { width: 200px; height: 150px; overflow: hidden; } .crop img { width: 400px; height: 300px; margin: -75px 0 0 -100px; }
You embed the img in a div with class .crop, or in-line the styles in the img and div tags.
--jeroen
Rate this:
Share this:
- Share on Mastodon (Opens in new window) Mastodon
- Share on Bluesky (Opens in new window) Bluesky
- Share on Tumblr
- Share on Reddit (Opens in new window) Reddit
- Share on Threads (Opens in new window) Threads
- Tweet
- Share on Telegram (Opens in new window) Telegram
- Share on Nextdoor (Opens in new window) Nextdoor
- Share on WhatsApp (Opens in new window) WhatsApp
- Print (Opens in new window) Print
- Email a link to a friend (Opens in new window) Email
Related
This entry was posted on 2021/08/25 at 12:00 and is filed under CSS, Development, HTML, HTML5, SocialMedia, Software Development, Web Development, WordPress, WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
This site uses Akismet to reduce spam. Learn how your comment data is processed.






Leave a comment