【问题标题】:How to bind in angular a style property of a placeholder input like text-indent of a placeholder如何以角度绑定占位符输入的样式属性,例如占位符的文本缩进
【发布时间】:2019-08-26 02:58:52
【问题描述】:

我知道我可以做到:

::-ms-input-placeholder,  /* Microsoft Edge */
:-ms-input-placeholder,   /* Internet Explorer 10-11 */
::placeholder  /* Chrome, Firefox, Opera, Safari 10.1+ */
{
  text-indent: 10px;
}

但我想使用投标属性 [style...]

<input type="text" [style.placeholder.text-indent.px]="customIndent">

【问题讨论】:

标签: css angular binding


【解决方案1】:

我不确定我是否理解您的问题,但是:

你可以试试这个

数字 = 10; 获取样式(){ 风格 = { '文本缩进:' : this.number + 'px' } 返回样式; }

并像这样使用:

<input type="text" [ngStyle]="getStyle()">

【讨论】:

  • 这与[style.text-indent]="customIndent" OP 要求样式伪类没有任何不同。
猜你喜欢
  • 1970-01-01
  • 2017-04-07
  • 2013-09-02
  • 2013-01-15
  • 1970-01-01
  • 2022-07-02
  • 2020-05-20
  • 2014-01-04
  • 2019-01-27
相关资源
最近更新 更多