Android Center Alignment Problem

My android app has webview to display html. In webview for the input field, we want the placeholder to be centered. Style placement

-webkit-input-placeholder {text-align: center;} 

but the placeholder does not align the center. It works great with the browser when testing. Can someone help me with this?

+6
source share
2 answers

Android has an error here :(, centering just wonโ€™t work. You can use this polyfill: https://github.com/diy/jquery-placeholder and this supports the โ€œforceโ€ attribute. This attribute forces it to run even in the browser, which "supports" the placeholder, for example, android.

 $('#myInput').placeholder({force:true}); 

Then use plain CSS to create the placeholder class provided by the plugin.

 .placeholder{ text-align: center; } 
+3
source
  ::-webkit-input-placeholder {text-align: center;} 

Try it.

or

 <!DOCTYPE html> <html> <head> <style> input::-webkit-input-placeholder { text-align: center; } </style> </head> <body> <input type="text" placeholder="asdf" /> </body> </html> 
+1
source

Source: https://habr.com/ru/post/954503/


All Articles