I am working on a React Native project. The container's flexDirection
is set to column
and I want the child's width to span 80% of the parent. If the parent's flexDirection
was set to row
I would have set the flex
value to 0.8
and be done with it. The restrictions are
Here is a playground to fiddle with the problem.
I recently learned that after ReactNative version 0.42 there is support for percentage units not just only for width but also the following properties:
padding
margin
width
height
minWidth
minHeight
maxWidth
maxHeight
flexBasis
If you want to learn more here is a link to the actual commit that added this awesome functionality.
The answer to my question would be to just add a percentage width of 80%
Here it is my original fiddle with the fix added.