Light Effect
HTML CODE:-
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <section></section> <div class="light"></div> </body> </html> |
CSS CODE:-
body{ padding: 0px; margin: 0px; } section{ position: relative; min-height: 100vh; background: #000; display: flex; justify-content: center; align-items: center; background-image: url("https://media.istockphoto.com/id/670688480/photo/green-tea-plantations-munnar-kerala-india.jpg?s=612x612&w=0&k=20&c=b09pbKjviHDfBg4sviMO5Pjwq_KhcpgsMHquKrLQBdU="); background-size: cover; background-position: center; } section img{ width: 100%; cursor: default; } .light{ position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; background: radial-gradient(circle at var(--x) var(--y),transparent 10%, rgba(0,0,0,0.95) 20%); } |
JS CODE:-
var circle=document.documentElement; circle.addEventListener('mousemove', e=>{ circle.style.setProperty('--x',e.clientX + 'px') circle.style.setProperty('--y',e.clientY + 'px') }) |