Center align placeholder issue in android

倖福魔咒の 提交于 2019-12-04 05:22:06

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;
}
  ::-webkit-input-placeholder {text-align: center;}

Try this.

Or

<!DOCTYPE html>
<html>
<head>
    <style>
        input::-webkit-input-placeholder
        {
            text-align: center;
        }
    </style>
</head>
<body>
    <input type="text" placeholder="asdf" />
</body>
</html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!