3
I’m on a project and I need an object on the side of the page that increases the height as the scroll.
The result I have achieved so far is "breaking" as I go down the scroll. How to get something that is more lively or has a smoother transition?
HTML:
<header>
</header>
<div id="content">
<div id="broca">
</div>
</div>
<footer>
</footer>
CSS:
header, footer{
display:block;
height:200px;
background:red;
width:100%;
}
#content{
display:block;
width:100%;
height:1500px;
background:blue;
}
#broca{
width:50px;
height:0;
background:#000;
}
jQuery:
$(function(){
$(window).scroll(function() {
var $broca = $('#broca');
var st = $(this).scrollTop();
if (st > $broca.height()){
$broca.height( st );
}
if( st == 0 ) {
} else {
$broca.show();
}
}).scroll();
})
Jader, it worked perfectly. Thank you very much.
– Mauro Alves