<div class="inputContainer">
<div class="inputPlaceholder">Hello world</div>
<input type="text" class="input" />
</div>
次のCSS:
.inputContainer{ position: relative; background-color: green; }
.input { position: absolute; top: 0px; left: 0px; background: transparent none; -webkit-appeareance: none; }
.inputPlaceholder { position: absolute; top: 0px; left: 0px; color: gray }
そして次JS:
$('.inputContainer .input').keyup(function(){
$(this).parent().find('.inputPlaceholder').hide();
if($(this).val() == ''){
$(this).parent().find('.inputPlaceholder').show();
}
});
問題はIEであり、プレースホルダのZ-インデックスのために入力テキストに集中することはできません。私は.inputPlaceholder z-indexを-1に、.inputを100に設定しようとしましたが、nothi他のブラウザでもうまくいっていますが、Foursquareはこの同じテクニックを検索ボックスで使用していました。
どうすればこの問題を解決できますか?その原因は何ですか?
ごめんメイト透明にする必要がありますが、それは働いていない:( – randomKek