問題はフォーカス機能が "名前"(最初のもの)で "電子メール"(2番目)ではなく、 。焦点が合っていると、背景の位置が変わり、黄色の境界線が作成され、最初の境界線に対しても正常に機能します。事前に入力forcusはfirefoxとchromeの1/2フィールドでしか動作しません
$("#formLeft input").focus(function() {
$(this).parent().addClass("active");
});
$("#formLeft input").blur(function() {
$(this).parent().removeClass("active");
});
CSS
#formLeft {
width: 320px;
float: left;
}
#formLeft input {
width: 250px;
border: none;
text-align: left;
background: none;
margin: 13px 0 0 13px;
font-size: 14px;
}
#formLeft .input-bg {
background: url(bilder/input-bg.jpg) top left no-repeat transparent;
height: 45px;
margin-bottom: 10px;
position: relative;
}
#formLeft div.active {
background: url(bilder/input-bg.jpg) bottom left transparent;
height: 45px;
margin-bottom: 10px;
position: relative;
}
HTML
<div id="formLeft">
<label for="Name">Name:</label>
<div class="input-bg">
<input type="text" name="Name" id="Name" class="required" minlength="2" />
</div>
<label for="Email">Email:</label>
<div class="input-bg">
<input type="text" name="Email" id="Email" class="required email" />
</div>
</div>
ありがとう:ここ
はjsのです!ここで
input-bg.jpgへの実際のパスを投稿できますか?テストが簡単になります。 – j08691
私の答えがあなたの質問を解決したなら、それを答えとして受け入れるべきです。そうでない場合は、私に知らせてください。 – Jason