How to float text around an image in

I am trying to achieve a very general effect in the reaction associated with moving text around the image. On the Internet, you must assign a float property to an image and follow it with the p tag. This is how I want my elements to flow .

Here is an example of RNPlay I was working on. I think that the method that I now have is a little hacky and does not work properly, as the text does not align with the top of the image and flows down. Is there a proper and clean way to do this?

+16
css flexbox react-native
source share
3 answers

Unfortunately, there is still no easy way to do this, even after introducing the nested View inside the Text . Surprisingly, in the iOS community, this seems nontrivial.

iphone - How to implement the "float" effect for an image, as in the CSS style https://github.com/Cocoanetics/DTCoreText/issues/438

One idea that would have come to my mind to work hard is to measure the text, size and / or character, and depending on the size of the image, divide the text into two Text components, one of which goes right / left, and the other below the image .

There is this vulnerable React Native library that can help, which allows you to measure the width and height of a Text component based on its contents:

https://github.com/alinz/react-native-swiss-knife/blob/master/lib/text/index.ios.js

+4
source share

You can use Text as a container instead of the typical View .

 <Text style={{flex: 1}}> <Image source={Images.IconExplore} style={{ width: 16, height: 16 }} /> <Text> Your past has been in control for far too long. It time to shift to a higher expression of what you are capable of so you can create the life you want to live.</Text> </Text> 

enter image description here

0
source share

Now you can use

 flexDirection: 'row' 
-2
source share

All Articles