我的页面内链接有问题.这是我在页面中使用的jQuery代码的一部分
$.fn.stopAtTop= function () {
var $this = this,
$window = $(window),
thisPos = $this.offset().top,
//thisPreservedTop = $this.css("top"),
setPosition,
under,
over;
under = function(){
if ($window.scrollTop() < thisPos) {
$this.css({
position: 'absolute',
top: ""
});
setPosition = over;
}
};
over = function(){
if (!($window.scrollTop() < thisPos)){
$this.css({
position: 'fixed',
top: 0
});
setPosition = under;
}
};
setPosition = over;
$window.resize(function()
{
bumperPos = pos.offset().top;
thisHeight = $this.outerHeight();
setPosition();
});
$window.scroll(function(){setPosition();});
setPosition();
};
Run Code Online (Sandbox Code Playgroud)
这是DEMO的一个例子
当我向下滚动时,一切正常,但是当我想要进入页面顶部时,这是不可能的.我知道问题是脚本div修复了,但我不知道如何解决它.有任何想法吗?
在我的项目中,我使用的操作系统不同,一台是Mac,第二台是Windows。当我使用git时,所有更改都显示为整个文档更改。原因是这两个OS的行尾不同。我阅读了此https://help.github.com/articles/dealing-with-line-endings/并.gitattributes在根文件夹中创建了一个文件,但问题仍然存在。这是我的.gitattributes文件:
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.css text
*.html text
*.js text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
Run Code Online (Sandbox Code Playgroud)
我不知道为什么它不起作用,因为我之前曾尝试过对该文件进行很多配置。