Hi,
To create a navigation bar that will shrink or enlarge specific elements when scrolling, you can use the CSS and Javascript solution below. You can modify it according to your needs, to resize the image, links, bar height and also choose when and how quick the resizing should occur.
<style>
* {box-sizing: border-box;}
body {
margin: 0;
font-family: Arial, Verdana;
}
#navigation_bar {
overflow: hidden;
position: fixed;
background-color: #444444;
transition: 0.3s;
width: 100%;
top: 0;
padding: 60px 15px 60px 15px;
z-index: 50;
}
#navigation_bar #logo {
transition: 0.3s;
}
#navigation_bar-links {
float: right;
}
#navigation_bar a {
text-decoration: none;
font-size: 17px;
line-height: 21px;
float: left;
color: #FFFFFF;
text-align: center;
padding: 13px;
}
#navigation_bar a:hover {
color: #208fff;
}
#navigation_bar a.active {
background-color: #208fff;
color: white;
}
</style>
<body>
<div id="navigation_bar">
<a href=""><img src="image.png" alt="logo image" id="logo" /></a>
<div id="navigation_bar-links">
<a href="" class="active">Menu 1</a>
<a href="">Menu 2</a>
<a href="">Menu 3</a>
</div>
</div>
<div style="margin: 200px 15px 2000px 15px;">
Text
</div>
</body>
<script type="text/javascript">
window.onscroll = function() {resizeNavigationBar()};
function resizeNavigationBar() {
if (document.documentElement.scrollTop > 60 || document.body.scrollTop > 60) {
document.getElementById("navigation_bar").style.padding = "30px 15px 30px 15px";
document.getElementById("logo").style.width = "125px";
} else {
document.getElementById("navigation_bar").style.padding = "60px 15px 60px 15px";
document.getElementById("logo").style.width = "160px";
}
}
</script>