给你改了。
你代码都发错了,控制它的位置 是CSS样式里面的定位。我已经改过了。你看下吧。
我是亿人,希望改过的对你有帮助。
$(function () {
var contachTop = 0; // 右侧联系我们默认高度
function Qust_contachScroll (){
var st = 0;
if (document.documentElement && document.documentElement.scrollTop) {
st = document.documentElement.scrollTop;
} else if (document.body) {
st = document.body.scrollTop;
}
var contactTop = $(".qust_contach").offset().top;
var height = $(".qust_contach").height();
if ( st>80) {
var top = (document.documentElement.clientHeight - height)/2+st -80;
$(".qust_contach").stop().animate(
{
top: top
},300,null,function(){
$("#toTop").stop().animate({
height:45
});
});
} else {
var top = (document.documentElement.clientHeight - height)/2 -80;
//$(".qust_contach").css({
//top: top
//});
if(top<=0)
{
top=contachTop
}
$(".qust_contach").stop().animate(
{
top: top
},300,null,function(){
$("#toTop").stop().animate({
height:0
});
});
}
}
function qust_showScroll(){
var st = 0;
if (document.documentElement && document.documentElement.scrollTop) {
st = document.documentElement.scrollTop;
} else if (document.body) {
st = document.body.scrollTop;
}
var contactTop = $(".qust_show").offset().top;
var height = $(".qust_show").height();
if ( st>80) {
var top = (document.documentElement.clientHeight - height)/2+st -80;
$(".qust_show").stop().animate(
{
top: top
},300);
} else {
var top = (document.documentElement.clientHeight - height)/2 -80;
//$(".qust_contach").css({
//top: top
//});
if(top<=0)
{
top=contachTop
}
$(".qust_show").stop().animate(
{
top: top
},300);
}
}
Qust_contachScroll();
qust_showScroll();
$(window).scroll(function () {
Qust_contachScroll();
qust_showScroll();
});
$(window).resize(function () {
Qust_contachScroll();
qust_showScroll();
});
$(".qst_close").click(function(){
$(".qust_contach").fadeOut(function(){$(".qust_show").fadeIn();});
});
$(".qust_show").click(function(){
$(".qust_show").fadeOut(function(){$(".qust_contach").fadeIn();});
});
$("#toTop").click(function(){
$(".qust_contach").stop().animate(
{
top: contachTop
},300);
jQuery("html, body").animate({ scrollTop: 0 }, 300);
});
});
你的这个代码比较老,css属性有好多都不支持,建议换个吧!高度控制在js2文件夹下的contact.js里修改,默认高度是100,我已修改成为0(已没有高度),没有用哟!