전체 화면 div에 요소가 있습니다. 내가»요소«및 페이드에서 div».section«의 배경 이미지로 이동하고 싶습니다. 배경 이미지 만 표시하는 것은 문제가 아니지만 페이드 애니메이션을 추가하는 방법에 대해서는 알지 못합니다.요소 위에 마우스를 놓고 부모 div의 배경을 희미하게합니다.
$(function() {
$('.element').hover(function() {
$('.section').css('background-image', 'url(https://ih0.redbubble.net/image.87373734.8395/flat,800x800,075,t.jpg)');
}, function() {
// on mouseout, reset the background
$('.section').css('background-image', '');
});
});
.section {
width: 400px;
height: 400px;
border: 1px solid black;
text-align: center;
transition: 1s ease all;
}
.element {
margin-top: 45%;
border: 1px solid red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="section">
<div class="element">hover me</div>
</div>
https://jsfiddle.net/sr1qj1pc/
당신이 나를 도울 수 있을까요?
가능한 중복 (https://stackoverflow.com/questions/12227901/배경으로 이미지가 희미 해짐) –