Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand image to fit container #600

Open
tonypeng opened this issue Aug 28, 2024 · 1 comment
Open

expand image to fit container #600

tonypeng opened this issue Aug 28, 2024 · 1 comment

Comments

@tonypeng
Copy link

as mentioned in #108, i've set a width on the parent container:

<div style={{width: 400}}>
  <ReactCrop ...>
    <img ... />
  </ReactCrop>
</div>

This works well when the image is larger than the container (the image is resized downward to fit in the container), but when the image is smaller than the container, it doesn't scale up to fit the container. Any way to accomplish this behavior?

@ayushgarg-git
Copy link

Hey @tonypeng
I used the "style" prop to specify width and height of the Crop container and added {width:"100%",height:"100%", objectFit:'contain'} as the style for the enclosed image. The image expands to the size that you specify for the Cropper nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants