This will help you to apply css as per scroll event
<script>
jQuery(document).ready( function() {
var topOfOthDiv = jQuery("#nav-topbar").offset().top;
jQuery(window).scroll(function() {
if(jQuery(window).scrollTop() > topOfOthDiv) {
jQuery("#nav-topbar").css({
"position":"fixed",
"width":"50%"});
}else{
jQuery("#nav-topbar").css({
"position":"static",
"width":"100%"});
}
});
});
</script>