在我的Android应用程序中有webview来显示html。 在webview中,对于输入字段,我们希望占位符居中对齐。 放置样式
-webkit-input-placeholder {text-align: center;}
但占位符不是对齐中心。我们测试时它与浏览器一起工作正常。 任何人都可以帮助我吗?
答案 0 :(得分:3)
Android有一个错误:(,居中只是不起作用。你可以使用这个polyfill:https://github.com/diy/jquery-placeholder并且它支持“force”属性。该属性使它甚至在“支持”的浏览器上运行占位符,就像android。
$('#myInput').placeholder({force:true});
然后使用常规CSS来设置插件提供的占位符类
.placeholder{
text-align: center;
}
答案 1 :(得分:2)
::-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>