0
私はjQuery animate(
関数を使って作業しており、以下を含んでいます。私は次のように私のbackground-image
不透明度を変更したいjqueryで.animate()の後で背景画像の不透明度を変更するにはどうすればいいですか?
$(document).ready(function(){
setInterval(function(){
$("#animate1").fadeIn('slow').animate({
'margin-left': '150px',
'margin-bottom': '50px'
}, 2000).fadeOut();
$("#animate1").fadeIn('slow').animate({
'margin-bottom': '0px',
'margin-left': '-140px'
}, 2000).fadeOut();
}, 300);
});
<div style="background-image:url('img/sofa.jpg');">
<div id="animate1">
<img src="img/chotu.png" style="height:200px; width:200px;"/>
</div>
</div>
:
$("#animate1").fadeIn('slow').animate({
'margin-left': '150px',
'margin-bottom': '50px'
}, 2000)./* change bg-opacity here */.fadeOut();
それは可能ですか?最初のアニメーション機能の後で背景画像の不透明度を変更したいだけです。
あなたは直接背景の不透明度に影響を与えることができません。要素全体の不透明度のみを変更することができます。また、要素の背景の不透明度を同じインスタンスで変更していない場合、その要素を完全に冗長にフェードアウトしますか? –
擬似要素を使用することができます。https://scotch.io/tutorials/how-to-change-a-css-background-images-opacity –