首页 > 其他 > 详细

超链接解决头部fixed问题

时间:2015-04-28 13:49:49      阅读:192      评论:0      收藏:0      [点我收藏+]

///////////超链接解决头部fixed问题


$(‘a[href*=#]‘).click(function () {
var top1 = $(".header").height(), top2 = $(".navigation").height(),l=top1+top2;
if (location.pathname.replace(/^\//, ‘‘) == this.pathname.replace(/^\//, ‘‘)
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target
|| $(‘[name=‘ + this.hash.slice(1) + ‘]‘);
if ($target.length) {
var targetOffset = $target.offset().top-l;
var obj = document.documentElement;
if (jQuery.browser.safari)
obj = document.body
if (jQuery.browser.msie)
obj = ‘html‘;
$(obj).animate({ scrollTop: targetOffset }, 1000);
return false;
}
}
});

超链接解决头部fixed问题

原文:http://www.cnblogs.com/tanghongbo/p/4462567.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!