7
is the following.. i have a floating banner on my blog using the following JS
$(function(){
var jElement = $('.element');
$(window).scroll(function(){
if ( $(this).scrollTop() > 2000 ){
jElement.css({
'position':'fixed',
'top':'30px',
'width':'360px'
});
}else{
jElement.css({
'position':'relative',
'top':'30px'
});
}
});
.element {
width: 100%;
margin-top: 30px;
padding: 10px;
background: #f9f9f9;
text-align: center;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="element hidden-xs">
conteudo
</div>
only that my floating scroll banner is passing the footer. my footer starts with tags
I would like a help to modify this JS so it does not get over the footer! My blog is: http://www.aisenhor.com.br
Take a look at this answer and jsFiddle it: http://answall.com/a/27180/129
– Sergio
@Sergio Sei, but I wanted to use my code, I just wanted to do something so he wouldn’t get on the footer!
– Luciano Oliveira Lima
So that’s there, on the last line...
if (scroll + alturaSidebar > alturaPagina - alturaFooter) sidebar.css('top', alturaPagina - scroll - alturaSidebar - alturaFooter);
– Sergio
@Sergio right! Thanks for the tip, but I’m layman in JS, I’m trying more not know how to adapt it in this my code!
– Luciano Oliveira Lima