我的安卓应用中有一个webview来显示html页面。 在webview中,对于输入框,我们想要让占位符居中对齐。 样式代码如下:
-webkit-input-placeholder {text-align: center;}
但占位符未对齐中心。在浏览器测试时,其工作良好。有人能帮忙吗?
我的安卓应用中有一个webview来显示html页面。 在webview中,对于输入框,我们想要让占位符居中对齐。 样式代码如下:
-webkit-input-placeholder {text-align: center;}
但占位符未对齐中心。在浏览器测试时,其工作良好。有人能帮忙吗?
Android在这里有一个bug :(,居中对齐就是不起作用。您可以使用这个polyfill:https://github.com/diy/jquery-placeholder,它支持“force”属性。该属性使其在即使是像android这样“支持”占位符的浏览器上也能运行。
$('#myInput').placeholder({force:true});
.placeholder{
text-align: center;
}
::-webkit-input-placeholder {text-align: center;}
请尝试这个。
或者
<!DOCTYPE html>
<html>
<head>
<style>
input::-webkit-input-placeholder
{
text-align: center;
}
</style>
</head>
<body>
<input type="text" placeholder="asdf" />
</body>
</html>