react-lazy-load icon indicating copy to clipboard operation
react-lazy-load copied to clipboard

Not responsive

Open Cam opened this issue 9 years ago • 7 comments

With the requirement of a fixed height setting, this plugin fails to work inside modern apps where responsive layouts are a standard requirement.

Cam avatar May 12 '16 04:05 Cam

You can specify a height in percentage

ganmor avatar Jul 18 '16 11:07 ganmor

That doesn't make it responsive, that makes is a % of the container height, whereas the image width is 100% is what dictates its height of auto.

ghost avatar Aug 28 '16 19:08 ghost

Instead of just height could you not expose a className and/or style?

ctrlplusb avatar Oct 07 '16 19:10 ctrlplusb

Is there any solution for this yet? Thanks!

xims avatar Feb 03 '17 12:02 xims

It should take ratio and calculate height based on width of component. Like responsive embed in foundation.

stereobooster avatar May 28 '17 18:05 stereobooster

Here is the solution

<LazyLoad className="responsive">
  <img src='http://apod.nasa.gov/apod/image/1502/HDR_MVMQ20Feb2015ouellet1024.jpg' alt='' width="1024" height="762" />
</LazyLoad>
.responsive {
  position: relative;
  height: 0;
  padding-bottom: 75%;
  overflow: hidden;
}

.responsive iframe,
.responsive object,
.responsive embed,
.responsive video,
.responsive img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

stereobooster avatar May 28 '17 22:05 stereobooster

Will add to the example.

loktar00 avatar Aug 23 '22 03:08 loktar00