【问题标题】:centering the position of blinking cursor without changing the position of placeholder居中闪烁光标的位置而不改变占位符的位置
【发布时间】:2019-01-01 14:07:18
【问题描述】:

我正在处理website,我想将闪烁光标的位置居中,占位符也居中。

此时在占位符what are you looking for...上,闪烁的光标从左至右开始,如下图所示。



我用于占位符和闪烁光标的 CSS 代码是:

闪烁光标

.input-searchicon input{
padding-left: 40px;
}

占位符:

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


}

:-moz-placeholder { /* Firefox 18- */
 text-align: center;  


}

::-moz-placeholder {  /* Firefox 19+ */
 text-align: center;


}

:-ms-input-placeholder {  
 text-align: center; 


}


问题陈述:

我想知道我应该在上面的 CSS 代码中进行哪些更改,以便 闪烁光标从中心开始,占位符也居中。

【问题讨论】:

    标签: html css cursor placeholder


    【解决方案1】:

    输入的文本也应该居中。将输入样式更改为:

    .input-searchicon input{
       padding-left: 40px;
       text-align: center;
     }
    

    【讨论】:

    • 感谢您的回答。我有一个类似的question。我想知道你是否可以看看。
    【解决方案2】:

    只需在input 上使用text-align: center

    .input-searchicon{
      text-align: center;
    }
    
    
    ::-webkit-input-placeholder {
     text-align: center;
    
    
    }
    
    :-moz-placeholder { /* Firefox 18- */
     text-align: center;  
    
    
    }
    
    ::-moz-placeholder {  /* Firefox 19+ */
     text-align: center;
    
    
    }
    
    :-ms-input-placeholder {  
     text-align: center; 
    
    
    }
    <input type="text" placeholder="what are you looking for" class="input-searchicon"/>

    【讨论】:

    • 感谢它的工作。我有一个类似的问题。我想知道您是否可以给我pointer 如何继续处理该问题。
    • @user5447339 没问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-22
    • 2012-03-23
    • 2015-06-05
    • 2014-12-14
    • 1970-01-01
    相关资源
    最近更新 更多