gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
make background image move when the mouse is inside the section container
- User
make background image move when the mouse is inside the section container
- Assistant
To make the background image move when the mouse is inside the section container, you can use CSS and JavaScript/jQuery.
- HTML: Wrap the content of the section container in a div and give it an id (e.g., "container").
<section> <div id="container"> <!-- Content here --> </div> </section>- CSS: Add styles to the container div to set the background image and other necessary properties.
#container { background-image: url('your-image.jpg'); background-size: cover; background-position: center; background-repeat: no-repeat; transition: background-position 0.5s ease; }- JavaScript/jQuery: Add the following JavaScript/jQuery code to detect mouse movements inside the container and update the background position accordingly.
$(document).ready(function() { $('#container').mouseenter(function() { $(this).css('background-position', 'top right'); // Update background position when mouse enters }).mouseleave(function() { $(this).css('background-position', 'center'); // Reset background position when mouse leaves }); });