2017-12-20 10 views
1

「%」サフィックスを追加します。が内部表示値に私は、次のようなタイプで<a href="https://github.com/react-toolbox/react-toolbox/tree/dev/components/input#input" rel="nofollow noreferrer">react-toolbox input component</a>「番号」を持って反応し、ツールボックスを入力番号

<Input 
    type="number" 
    step="0.01" 
    value={itemValue} 
    onChange={this.handleInputChange.bind(this, item)} 
/> 

をそれは、だから、2.68

enter image description here

表示します入力フィールド内に2.68%で表示することが可能です

enter image description here

また、値が変更されるたびに接尾辞 "%"が表示されたままにしておく必要があります。

答えて

1

React-toolboxの<Input />は、<input>タグを子として使用しているdivです。必要なものを得るためにCSSを使用することもできますが、適切なclassNameをコンポーネントの用途に追加してください。

.rt-input-input { 
 
    position: relative; 
 
    display: inline-block; 
 
} 
 

 
.rt-input-input::after { 
 
    content: '%'; 
 
    font-family: sans-serif; 
 
    width: 1em; 
 
    height: 1em; 
 
    position: absolute; 
 
    top: 50%; 
 
    right: 5px; 
 
    
 
    transform: translateY(-50%); 
 
}
<div class="rt-input-input"> 
 
    <input type="text" value="2.68" /> 
 
</div>

それらが反応する、ツールボックスの入力コンポーネントクラスとして

+0

ないbefore/after擬似要素を持たないように、これは、正規inputタグに動作しません注意 '.rtであります-input-input'; 提案された解決策で '.input'を' .rt-input-input'に変更することで問題が解決しました。ありがとう。 –

+0

ああ、申し訳ありません、私はちょうどあなたが実際のクラス名についてゼロのエフェクトを与えるCSSモジュールに慣れています:) – casraf

関連する問題