これが解決策のフィドルです。これには、透明度のある別の絶対配置 div を使用することが含まれます。
http://jsfiddle.net/jessekinsman/xywKm/3/
HTML
<div class="container">
<div class="background">
</div>
<input type="text" name="test" class="white" />
</div>
CSS
* {
box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.container {
width: 200px;
height: 50px;
overflow: hidden;
position: relative;
}
.background {
position: absolute;
left: 100%;
background: red;
width: 100%;
height: 100%;
-webkit-transition: left 300ms linear;
transition: left 300ms linear;
opacity: 0.5;
-webkit-opacity: 0.5;
z-index:0;
}
.background.view {
left: 0;
}
.white {
background-color: white;
}
.red {
background-color: red;
}
input {
background-color: transparent none;
width: 100%;
height: 100%;
z-index: 100;
}
クラスを追加および削除するためだけのjQuery
$("input").focus(function(e){
$(".background").addClass("view");
});
$("input").focusout(function(e){
$(".background").removeClass("view");
});
入力要素に緩めたくない特定のスタイリングがない限り、おそらく最良のオプションです。次に、背景画像を使用する必要があります。
ここにそのフィドルへのリンクがあります
http://jsfiddle.net/jessekinsman/5aL4L/1/
また、いくつかの基準が満たされるまでアニメーションをループさせたいかどうかもわかりませんでした。その場合は、css 変換オプションを使用して、条件が満たされるまでループさせる必要があります。