react-native-htmlview icon indicating copy to clipboard operation
react-native-htmlview copied to clipboard

Style for responsive image.

Open tkserver opened this issue 6 years ago • 4 comments

I have an issue with images. I want to use a "responsive" view of the images which is essentially like this: const styles = StyleSheet.create({ img: { maxWidth: '100%', height: 'auto' } });

This above does not work.

I can add width and height attributes to the tag, but the problem with that is I don't know the dimensions of the image. The image might be portrait, landscape, square etc. So scaling with fixed values will certainly mess up the image dimensions.

tkserver avatar Aug 03 '18 03:08 tkserver

Bumping this since it has been 3 months and no response.

tkserver avatar Nov 05 '18 18:11 tkserver

Create a new component and get the width and height in his life cycle like this

Image.getSize(this.props.url, (width, height) => { this.setState({ width, height }) }, (err) => { console.log('err', err) })

leeleoo avatar Nov 15 '18 08:11 leeleoo

Thanks for the response @leeleoo but how can I do that when the image is in an image tag within a large block of HTML being rendered?

tkserver avatar Aug 09 '19 02:08 tkserver

how do we select a class and how do we define various selectors in stylesheet or style ??

<div class='main-container'>
          <div class='privacy-policy'><p>To view our privacy policy, scan the QR code below or visit https://abc.com/privacy-policy.</p></div>
      </div>

how do we select main-container here ??

4mit avatar Apr 05 '24 10:04 4mit