User
User

Reputation: 24731

Why doesn't height automatically adjust to the width?

In CSS, if you set a width of 60%, the height will proportionally adjust. In React Native, that is not the case. If you set the width of an image to be '60%', and don't set the height, the height will be 0 and not show. How do I get the height to do the same as CSS?

thumbnail: {
    width: '60%',
    minHeight: 10,
}

I tried setting a minHeight, and that makes it go to 10px. I want the height to change based on the image proportions. I looked at flex, but I don't think that's what I want.

enter image description here

Upvotes: 3

Views: 635

Answers (1)

klvs
klvs

Reputation: 1177

I think you want to set the resizeMode to contain. It could be cover, it looks like there's currently a mistake in the docs... https://facebook.github.io/react-native/docs/image.html

Upvotes: 1

Related Questions