ok
Direktori : /proc/thread-self/root/proc/self/root/proc/thread-self/root/home2/selectio/www/renew-right/ |
Current File : //proc/thread-self/root/proc/self/root/proc/thread-self/root/home2/selectio/www/renew-right/div.php |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Image Comparison Slider</title> <link rel="stylesheet" href="styles.css"> </head> <body> <style> .image-container { position: relative; width: 500px; /* Adjust the width as per your image size */ height: 300px; /* Adjust the height as per your image size */ overflow: hidden; } .before-image, .after-image { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; } .before-image { background-image: url('https://spinnpress.in/wp-content/uploads/2022/08/Before-shoe1.jpg.webp'); } .after-image { background-image: url('https://spinnpress.in/wp-content/uploads/2022/08/After-shoe1.jpg.webp'); clip-path: inset(0 50% 0 0); /* Initially show only the left half of the after image */ } .slider { position: absolute; top: 0; left: 50%; width: 2px; height: 100%; background-color: #fff; cursor: ew-resize; /* Cursor shape when hovering over the slider */ z-index: 100; } </style> <div class="image-container"> <div class="before-image" id="beforeImage"></div> <div class="after-image" id="afterImage"></div> <div class="slider" id="slider"></div> </div> <script> const slider = document.getElementById("slider"); const beforeImage = document.getElementById("beforeImage"); const afterImage = document.getElementById("afterImage"); const imageContainer = document.querySelector(".image-container"); let isDown = false; slider.addEventListener("mousedown", (e) => { isDown = true; imageContainer.classList.add("dragging"); updateSlider(e.pageX); }); document.addEventListener("mouseup", () => { isDown = false; imageContainer.classList.remove("dragging"); }); document.addEventListener("mousemove", (e) => { if (!isDown) return; updateSlider(e.pageX); }); function updateSlider(x) { const rect = imageContainer.getBoundingClientRect(); let posX = x - rect.left; posX = Math.max(0, Math.min(posX, rect.width)); // Limit slider movement within container width slider.style.left = posX + "px"; afterImage.style.clipPath = `inset(0 ${rect.width - posX}px 0 0)`; } </script> </body> </html>