Looking to create a sticky bar with a smooth CSS transition instead of the current rough effect. Any tips or hints would be greatly appreciated! For reference, I found the exact animation I'm aiming for on this website: https://css-tricks.com/
Here is the CSS code:
#bar {
display:inline-block;
width: 100%;
height: 50px;
max-height:50px;
background-color: #595959;
box-shadow: 0px 2px 2px #888888;
}
.bar-fixed {
top: 0;
z-index: 9999;
position: fixed;
width: 100%;
}
And here is the jQuery responsible for adding the necessary classes:
$(document).ready(function() {
$(window).scroll(function () {
console.log($(window).scrollTop());
if ($(window).scrollTop() > 59) {
$('#bar').addClass('bar-fixed');
}
if ($(window).scrollTop() < 60) {
$('#bar').removeClass('bar-fixed');
}
});
});
I've attempted to achieve this using CSS transitions without success. It seems like jQuery might be the way to go, but I could use some guidance or resources such as tutorials or courses to help me learn and make informed decisions. Thank you!