help?

[ad_1]

i got this code and i want to resize an image as you scroll down, i use the html widjet but it will not work for the life of me. it just streaches the page. anyone can help?

<!DOCTYPE html>

<html>

<head>

<style> body { overflow: hidden; margin: 0; } \&#x200B; .container { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); overflow: hidden; max-height: 100vh; max-width: 100vw; transition: transform 0.3s ease; } \&#x200B; .image { max-width: 100%; transform-origin: center center; } </style>

</head>

<body>

<div class=”container”>

<img class=”image” src=”\[http://localhost/Imperialhospitality/wp-content/uploads/2023/04/21.jpg\](http://localhost/Imperialhospitality/wp-content/uploads/2023/04/21.jpg)” alt=”Image”>

</div>

<script> // Get the image element var image = document.querySelector(‘.elementor-image img’); \&#x200B; // Add scroll event listener window.addEventListener(‘scroll’, function() { // Calculate the scroll progress as a percentage var scrollProgress = window.scrollY / (document.body.scrollHeight – window.innerHeight); \&#x200B; // Calculate the scale factor for the image var scale = 1 – scrollProgress; \&#x200B; // Apply the transformation using scale image.style.transform = ‘scale(‘ + scale + ‘)’; }); \&#x200B; </script>

</body>

</html>

[ad_2]
1 Comment

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer