Canvas ignores object-fit property
See original GitHub issueWhen using any object-fit setting, its being ignored and images are simply stretched to fill the space due to flexbox props.
.bt-create-post-images-container {
min-width: 100%;
background-color: #8f8f8f;
height: 350px;
overflow: hidden;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.bt-create-post-image-container {
background-color: #8f8f8f;
height: 100%;
overflow: hidden;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.bt-create-post-image-container > img {
width: 100%;
height: 100%;
object-fit: cover;
align-self: auto;
vertical-align: middle;
}
<div class="bt-create-post-images-container" id="images">
<div class="bt-create-post-image-container {{type == 'versus' && 'flex-versus' || ''}}">
<img ng-show="show_left" ng-src="{{uri_left}}">
</div>
<div class="bt-create-post-image-container {{type == 'versus' && 'flex-versus' || ''}}">
<img ng-show="show_right" ng-src="{{uri_right}}">
</div>
</div>
Issue Analytics
- State:
- Created 8 years ago
- Reactions:6
- Comments:14
Top Results From Across the Web
Html2canvas Ignores Object fit for image - Stack Overflow
I noticed an image inside the div element that uses the object-fit property becomes stretched after the html2canvas screenshot.
Read more >object-fit - CSS: Cascading Style Sheets - MDN Web Docs
The object-fit CSS property sets how the content of a replaced element, such as an or , should be resized to fit its...
Read more >Object Fit - Tailwind CSS
Using an element's original size. Display an element's content at its original size ignoring the container size using .object-none .
Read more >The canvas state - HTML Standard, Edition for Web Developers
A canvas element can be sized arbitrarily by a style sheet, its bitmap is then subject to the 'object-fit' CSS property.
Read more >Embedded Content — SVG 2
The object-fit and object-position affect the final position and size of the ... attribute on the root element in the referenced SVG image...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Are there updates regarding this issue? Has anyone found a workaround?
FYI, there’s a different solution/workaround, as I struggled with
object-fit
andobject-position
. Instead of using animg
, use adiv
with following CSS: