position?:fixed not working on chrome browser but it works fine in firefox.
I have a sidebar that stop scrolls and stick to top. it works perfect in firefox but in chrome the sidebar disappears as we scroll to the sidebar position.
But the same code works on another site.. I'm confused...
my html
<div class="wraper">
<div id="fixme">
<img src="example.com/images/ps14_homepage.jpg" style="width:100%;" alt="ad image">
</div>
</div>
here is my javascript to fix the block at a certain height
var fixmeTop = $('#fixme').offset().top;
jQuery(function($) {
function fixDiv() {
var $cache = $('#fixme');
if ($(window).scrollTop() > fixmeTop)
$cache.css({
'position': 'fixed',
'top': '10px',
});
else
$cache.css({
'position': 'relative',
'top': 'auto'
});
}
$(window).scroll(fixDiv);
fixDiv();
});
CSS
.wraper {float:left;display:block;position:relative; height:auto; border:1px solid #000; width:100%;}