Sencha Touch 2:在Android 4中未居中输入占位符

Sencha Touch 2: input placeholder in not centered in Android 4

本文关键字:输入 占位符 Android Touch Sencha      更新时间:2023-09-26

我正在尝试将占位符文本居中。它看起来以IOS为中心,但在Android 4上仍然保持左对齐。

/*css code is below*/
    #myinput input{
        text-align:center!important;
     }
    #myinput input::-webkit-input-placeholder{
        text-align:center!important;
     }

//the view (.js file) has
{
    xtype: 'emailfield',
    name: 'myinput',
    id: 'myinput',
    required: true,
    placeHolder: 'myinput (optional)',
    listeners: {
      //some listeners are here
    }
}

我错过了什么?

Android有一个错误:(,居中不起作用。你可以使用这个polyfill:https://github.com/diy/jquery-placeholder并且它支持"force"属性。这个属性使得它甚至可以在"支持"占位符的浏览器上运行,比如android。

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

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

.placeholder{
  text-align: center;
}

写这篇文章的标准方法如下:

#myinput::-webkit-input-placeholder{
        text-align:center!important;
}

#myinput之后没有"输入",请尝试!