$(function(){
$(window).scroll(function(){
var h=$("body").scrollTop();
if(h>200){$(".aaa").css("top","0px");}else if(h<200){$(".aaa").css("top","100px");}
})
})
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
window.onscroll = function () {
var t = document.documentElement.scrollTop || document.body.scrollTop;
if (t > 0&&t<500) {
$(".aaa").css("height","50");
} else if(t>500&t<1000) {
$(".aaa").css("height","100");
}
</script>
<style type="text/css">
.aaa{background-color:red;height:80px;100px;position: fixed;top:100px}
</style>
</head>
<body style="height:7500px">
<div class="aaa"></div>
</body>
<ml>
<html>
<head>
<title></title>
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
window.onscroll = function () {
var t = document.documentElement.scrollTop || document.body.scrollTop;
if (t > 0&&t<500) {
$(".aaa").css("height","50");
} else if(t>500&t<1000) {
$(".aaa").css("height","100");
}
</script>
<style type="text/css">
.aaa{background-color:red;height:80px;100px;position: fixed;top:100px}
</style>
</head>
<body style="height:7500px">
<div class="aaa"></div>
</body>
<ml>