I am trying to fix the position of my share icons on windows scroll. so i set the position fixed on scroll event. Its not working properly.
- position fixed important is not working.
If i scroll up at the starting point(at the place where scroll stops) the default is not replicated. CSS edited js:
$(document).ready(function () { var shareLink = $('#article_tools'); function setHeader(){ if($(window).width() <= 990){ var shareLink = $('#article_tools'); if( shareLink.length > 0) { shareLink.prepend($(".social-share-custom")); shareLink.next().css({'margin-top': shareLink.outerHeight(true) + "px", 'float': 'left'}); } else{ var social_alone = $(".social-share-custom"); $(".evt_detail_main").before(social_alone); social_alone.next().css('float', 'left'); } $(".author-article-info, .orange_oval, .author-article-organization").wrapAll('<div class="author-details"></div>'); } if ($(window).width()<768) { shareLink.prepend($(".social-share-custom")); $('.follow-login-wrapper').append($('#top-login')); $('.responsive-menu').append($("#simplemenu")); $('#logo-title').after($('#container-search')); $('#homemenu').after($('#primary').find('>ul>li')); $('#comments').before($('#sidebar-right').find('#sidebar-right-inner>#block-constant_contact-0')); }}
$( window ).resize(function() { setHeader(); });
$(window).scroll(function(){ if($(window).width()<=990) { if (shareLink.length > 0) { shareLink.next().css('margin-top', shareLink.outerHeight(true) + "px"); shareLink.css("top", Math.max(0, 274 - $(this).scrollTop())); shareLink.css('background-color', 'white'); } else{ var social_alone = $(".social-share-custom"); social_alone.next().css('margin-top', shareLink.outerHeight(true) + "px"); social_alone.css("top", Math.max(0, 200 - $(this).scrollTop())); if(social_alone.css("top") == "0"){ social_alone.attr('style','position: fixed !important'); } social_alone.css({'background-color':'white','width':'64%'}); } }});
setHeader(); });
css:
.social-share-custom {
float: left;
width: auto;
position: static !important;
margin: 1%
}
some one do this trick.