Dynamic Box Shadow

Size
2,407 Kb
Views
44,528

How do I make an dynamic box shadow?

What is a dynamic box shadow? How do you make a dynamic box shadow? This script and codes were developed by Drew McConville on 31 August 2022, Wednesday.

Dynamic Box Shadow Previews

Dynamic Box Shadow - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Dynamic Box Shadow</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Scroll to Element</h1>
<div id="el"></div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Dynamic Box Shadow - Script Codes CSS Codes

body { min-height: 1900px; background-color: #e7eaee;
}
h1 { text-align: center; font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-weight: 300; color: #787a7f; margin-top: 200px;
}
#el { border-radius: 5px; height: 100px; width: 300px; padding: 1rem; margin: 0 auto; background-color: #FFF; margin-top: 700px; box-shadow: 0px 40px 20px 0px rgba(0, 0, 0, 0.2);
}

Dynamic Box Shadow - Script Codes JS Codes

$(document).scroll(function(){ winHeight = $(window).innerHeight(); topDif = $("#el").offset().top; elHeight = $("#el").innerHeight(), scrollTop = $(window).scrollTop(), distance = ((topDif - scrollTop) + elHeight), fromBottom = (winHeight - distance), percentScroll = (fromBottom / winHeight), pixelNum = ((percentScroll * 60) - 30) * (-1); $('#el').css('box-shadow', '0px ' + pixelNum + 'px 40px 0px rgba(0,0,0,0.2)');
})
Dynamic Box Shadow - Script Codes
Dynamic Box Shadow - Script Codes
Home Page Home
Developer Drew McConville
Username drew_mc
Uploaded August 31, 2022
Rating 4
Size 2,407 Kb
Views 44,528
Do you need developer help for Dynamic Box Shadow?

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!

Drew McConville (drew_mc) Script Codes
Create amazing art & images 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!