Image moves with mouse

Developer
Size
1,974 Kb
Views
20,240

How do I make an image moves with mouse?

What is a image moves with mouse? How do you make a image moves with mouse? This script and codes were developed by Lisa Macken on 01 October 2022, Saturday.

Image moves with mouse Previews

Image moves with mouse - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>image moves with mouse</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <body> <div id="landing-content"> <section class="slider"> <img></img> </section> <!-- <section class="slider2"> <img></img> </section> --> </div>
</body> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Image moves with mouse - Script Codes CSS Codes

 #landing-content {
overflow: hidden;
/*background-image: url(images/text1.png);*/
width: 100%;
background-repeat: no-repeat;
max-height: 800px;
border-bottom: solid;
border-bottom-color: #628027;
border-bottom-width: 5px;
}
.slider { background-image: url(http://lorempixel.com/400/200/); background-repeat: no-repeat;
margin-left: auto;
margin-right: auto;
overflow: hidden;
padding-top: 200px;
max-width: 1002px;
}
.slider2 { background-image: url(http://lorempixel.com/400/200/); background-repeat: no-repeat;
margin-left: auto;
margin-right: auto;
overflow: hidden;
padding-top: 200px;
max-width: 802px;
}
.slider img {
width: 80%;
padding-left: 10%;
padding-right: 10%;
height: auto;
margin-left: auto;
margin-right: auto;
}

Image moves with mouse - Script Codes JS Codes

$('.slider').mousemove(function(e){ var amountMovedX = (e.pageX * -2 / -4); var amountMovedY = (e.pageY * -2 / -4); $(this).css('background-position', amountMovedX + 'px ' + amountMovedY + 'px');
});
$('.slider2').mousemove(function(e){ var amountMovedX = (e.pageX * -1 /-4); var amountMovedY = (e.pageY * -1 / -4); $(this).css('background-position', amountMovedX + 'px ' + amountMovedY + 'px');
});
Image moves with mouse - Script Codes
Image moves with mouse - Script Codes
Home Page Home
Developer Lisa Macken
Username lmack90
Uploaded October 01, 2022
Rating 3
Size 1,974 Kb
Views 20,240
Do you need developer help for Image moves with mouse?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Lisa Macken (lmack90) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!