Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native-webview : For iOS text too small

Tags:

I have used react-native-webview for rendering HTML text. But text is too small in iOS while in android it is perfect.

Here are lines of code :

import { WebView } from "react-native-webview";   render() {   <WebView         originWhitelist={['*']}         source={{ html: '<p>This is a static HTML source!</p>' }}   /> } 

Attaching screenshot :

enter image description here

like image 443
Payal Maniyar Avatar asked Mar 05 '19 07:03

Payal Maniyar


People also ask

How do you set Webview height to the height of HTML content in react native?

The WebView has default styles. If you want to set height, you also need to add flex: 0 , as stated in the documentation: Please note that there are default styles (example: you need to add flex: 0 to the style if you want to use height property).


2 Answers

Using the viewport meta tag to control layout on mobile browsers

<meta name="viewport" content="width=device-width, initial-scale=1">  <WebView       originWhitelist={['*']}       source={{ html: '<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0"></head><body><p>This is a static HTML source!</p></body></html>' }} /> 

link :https://github.com/react-native-community/react-native-webview/issues/386

like image 80
Payal Maniyar Avatar answered Sep 27 '22 00:09

Payal Maniyar


Additionally to the <meta> you can add <style> tag into the <head> section to scale the font:

<style>     body { font-size: 120%; word-wrap: break-word; overflow-wrap: break-word; } </style> 
like image 43
Serhii Harbovskyi Avatar answered Sep 26 '22 00:09

Serhii Harbovskyi