In my android application there is webview to display html. In webview, for input field, we want placeholder to center align. Placing style
-webkit-input-placeholder {text-align: center;}
but placeholder is not aligning center. it's working fine with browser when we test. Could any one help me on it?
In most of the browsers, placeholder texts are usually aligned in left. The selector uses text-align property to set the text alignment in the placeholder. This selector can change browser to browser.
To change TextInput placeHolder alignment with React Native, we can set the textAlign style to 'center' . to align the placeholder at the center of the screen by setting textAlign set to 'center' .
Android has a bug here :(, centering just won't work. You can use this polyfill: https://github.com/diy/jquery-placeholder and it supports the "force" attribute. That attribute makes it run even on browser that "support" placeholder, like android.
$('#myInput').placeholder({force:true});
Then use regular CSS to style the placeholder class provided by the plugin
.placeholder{
text-align: center;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With