I wanted to stick the 2nd div when we scroll down the page and when the 2nd div meets the top boundary. When it\'s fixed, it should scroll along with the other pages. How ca
You can get this effect with jquery
$(function(){
// Check the initial Poistion of the Sticky Header
var stickyHeaderTop = $('#stickyheader').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyHeaderTop ) {
$('#stickyheader').css({position: 'fixed', top: '0px'});
$('#stickyalias').css('display', 'block');
} else {
$('#stickyheader').css({position: 'static', top: '0px'});
$('#stickyalias').css('display', 'none');
}
});
});
DEMO HERE
NOTE: Don't forget to include jquery library link in your page (assuming you as beginner)