image comparion slider using Html Css & Java Script

<!DOCTYPE html> <html> <head> <title>Change</title> </head> <body> <section> <div id="layer"></div> </section> <script type="text/javascript"> var slide = document.getElementById('layer'); window.onmousemove = function (e) { var x = e.clientX; slide.style.left = x + 'px'; } </script> </body> </html> <style type="text/css"> body{margin: 0px; padding: 0px; } section{ position: absolute; width: 100%; height: 100vh; overflow: hidden; background: url(img-1.jpg)no-repeat; background-attachment: fixed; } #layer{ position: absolute; top: 0px; left: 0px; width: 100%; height: 100vh; background: url(img-2.jpg)no-repeat; border-left: 2px solid #000; background-attachment: fixed; } </style>