6

在我的 android 应用程序中有 webview 来显示 html。在 webview 中,对于输入字段,我们希望占位符居中对齐。摆放方式

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

但占位符未对齐中心。当我们测试时,它在浏览器上运行良好。有人可以帮我吗?

4

2 回答 2

3

Android在这里有一个错误:(,居中不起作用。您可以使用这个polyfill:https ://github.com/diy/jquery-placeholder它支持“force”属性。该属性使它甚至可以运行“支持”占位符的浏览器,例如 android。

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

然后使用常规 CSS 对插件提供的占位符类进行样式设置

.placeholder{
  text-align: center;
}
于 2013-11-07T19:53:22.417 回答
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>
于 2013-09-24T13:06:43.800 回答