2017-03-22 5 views
1

プレースホルダ属性を持つ空の入力フィールドでtext-alignプロパティを無視するバグがあります。Microsoft Edge:テキストアライメントバグのプレースホルダを処理する方法

https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/4468563/

https://connect.microsoft.com/IE/feedback/details/1743283/microsoft-edge-placeholder-with-text-align-right-bug

ライブデモ:http://jsfiddle.net/z4fkev4v/

<h3>text-align: right</h3> 
<input class="right" type="text" /> 
<input class="right" type="text" placeholder="wrong cursor alignment" /> 

.right { 
text-align: right; 
} 

この問題を解決するための任意の解決策はありますか?

+0

// Bug fix for Microsoft Edge. Inputs with Placeholders and text-aligns other than left. if (navigator.userAgent.match(/Edge\/(.*)\./)) { $(function() { $("input[placeholder]").focusin(function() { var $this = $(this); if ($this.css("text-align").toLowerCase() != "left") { $this.attr("data-placeholder", $this.attr("placeholder")); $this.attr("placeholder", ""); } }).focusout(function() { var $this = $(this), tempPlaceholder = $this.attr("data-placeholder"); if (tempPlaceholder != "") { $this.attr("placeholder", tempPlaceholder); $this.attr("data-placeholder", ""); } }); }); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <input placeholder="This is an example" style="text-align: right" />
はプレースホルダが正しく整列されているMicrosoftエッジ38.14393.0.0 – zgood

+0

に私のために発生しませんが、カーソルが – asdfboy

+0

がはい、私は理解して左側に残っている...カーソルが上でしたエッジの私のために右 – zgood

答えて

0

ちょうど@DMCISSOKHOからのコードの修正版を追加したいです。これにより、Microsoft Edgeがチェックされ、プレースホルダ付きのすべての入力にのみ接続されます。また、フォーカスアウトが呼び出されたときにプレースホルダを使用します。私はjQueryを使わないように変更できると確信していますが、それは私の必要条件ではありません。

関連する問題