I've been working on designing a navigation bar for a website, but I'm running into some issues. My goal is to have the logo shrink as the user scrolls down the site. I've experimented with webkit animations and various javascript/jQuery functions, but nothing seems to be working properly. The current function I've tried doesn't seem to be cooperating. How can I go about fixing this?
Here is the HTML code I've been playing around with:
<html>
<body>
<script>
$(document).on("scroll", function() {
if($(document).scrollTop() >= 1)
{
$(".nav .logo img").css('-webkit-transform', 'scale(.5, .5');
$(".nav .logo img").css('-ms-transform', 'scale(.5, .5');
$(".nav .logo img").css('transform', 'scale(.5, .5');
}
else
{
$(".nav .logo img").css('-webkit-transform', 'scale(1, 1');
$(".nav .logo img").css('-ms-transform', 'scale(1, 1');
$(".nav .logo img").css('transform', 'scale(1, 1');
}
});
</script>
<div class="nav">
<div class = "logo">
<a href = "index.html"><img src="Pics/siren.png" alt="" width="196" height="196"/></a>
</div>
</div>
</body>
</html>
And here is the CSS code for styling the navigation elements:
.nav{
position: fixed;
top: 0;
z-index: 1;
width: 100%;
height: 100px;
}
.nav .logo{
position: fixed;
text-align: left;
z-index: 2;
top: 0;
bottom: 100px;
overflow: hidden;
opacity: .5;
}