【问题标题】:HTML change placeholder directionHTML 更改占位符方向
【发布时间】:2014-04-02 12:58:12
【问题描述】:

如何在input 标记占位符中扩展该父样式,我希望在left 样式输入中有right direction

例如这是我的输入:

<input type="password" style='direction:ltr;text-align:left;' id="password" placeholder="password">

placeholder text-align 现在被留下。如何使用direction:rtl

【问题讨论】:

    标签: html css


    【解决方案1】:

    我认为这可以帮助你。

    input[type="text"]:-moz-placeholder {
        text-align: right;
    }
    input[type="text"]:-ms-input-placeholder {
        text-align: right;
    }
    input[type="text"]::-webkit-input-placeholder {
        text-align: right;
    }
    

    Demo

    【讨论】:

      【解决方案2】:

      根据文档:(http://www.w3.org/html/wg/drafts/html/master/forms.html#the-placeholder-attribute)

      在控件的内容具有一个方向性但 占位符需要有不同的方向性,Unicode 的 双向算法格式化字符可用于 属性值:

      【讨论】:

        【解决方案3】:

        或者你可以专注于:

        input[type='text']{
        text-align:right;
        }
        
        input[type='text']:focus{
        text-align:left;
        }  
        

        虽然这不是你问的那样,但对我来说似乎更好,因为许多浏览器,如 Firefox 3 和 IE 8、9 不支持更改占位符的样式。 From this answer

        【讨论】:

          猜你喜欢
          • 2021-05-08
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-07-16
          • 1970-01-01
          • 2011-08-09
          • 2012-08-03
          • 2014-01-07
          相关资源
          最近更新 更多