question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image not scaling responsively both width & height

See original GitHub issue

Hello

ReactCrop container doesn’t seem to be containing the img (ReactCrop__image) when scaling. I can have it scale at smaller sizes but when the ReactCrop container height reaches my component height ReactCrop__image continues to grow.

Is there any CSS examples where the container, image and crop selection all scale proportionally and when boundaries are met all 3 stop scaling? My latest attempt is below where ReactCrop div is positioned centre centre in my component.

.component {
	position: relative;
	width: 100%;
	height: calc(100vh - 480px);
	.ReactCrop {
		display: block;
		position: absolute;
		top: 50%;
		left: 50%;
		width: auto;
		height: auto;
		max-height: 100%;
		transform: translate(-50%, -50%);
		.ReactCrop__image {
			display: block;
			width: auto;
			max-width: 100%;
			height: auto;
			max-height: 100%;
		}
	}
}

Cheers

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jakubwolnycommented, May 23, 2018

@DominicTobias fixed! thx a lot!

0reactions
jedierikbcommented, Mar 19, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting Height And Width On Images Is Important Again
To prevent layout shifts and improve performance scores, we need to always set width and height attributes on our images.
Read more >
How to Resize Images Proportionally for Responsive Web ...
Another way of resizing images is using the CSS width and height properties. Set the width property to a percentage value and the...
Read more >
Responsive Image Resize Issue - Stack Overflow
What you need to do is give the image a width of 100% and a height of auto. This will make it stay...
Read more >
Responsive Web Design Images - W3Schools
Resize the browser window to see how the image scales to fit the page. Using The width Property. If the width property is...
Read more >
CSS Responsive Image Tutorial: How to Make Images ...
To make an image responsive, you need to give a new value to its width property. Then the height of the image will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found