页面从菜单锚点滚动到右页但不从直接链接滚动到右页

时间:2015-07-06 14:16:43

标签: javascript jquery html css anchor

我正在使用这个免费脚本

http://codyhouse.co/gem/css-faq-template/

http://codyhouse.co/demo/faq-template/index.html#payments

该演示与我的网站存在同样的问题,尽管在我的网站上情况更糟。

如果您使用菜单,一切正常。标题上方有一些空格。

enter image description here

但是,如果您不是从菜单中访问直接链接http://codyhouse.co/demo/faq-template/index.html#payments

看起来像这样

enter image description here

正如您所看到的,标题“付款”上方没有空格。

在我的页面上更糟糕。它从“我可以......”开始,标题被隐藏。当我从链接直接访问页面时无法找到我可以调整的位置,而不会影响我从菜单访问该部分时的外观。

当用户点击某个部分时

/* Class = "UITableViewSection"; footerTitle = "..."; ObjectID = "cHU-BB-3aF";*/
"cHU-BB-3aF.footerTitle" = "Localized Footer Title"; // this does not work

/* Class = "UITableViewSection"; headerTitle = "Payment Details"; ObjectID = "cHU-BB-3aF"; */
"cHU-BB-3aF.headerTitle" = "Localized Header Title";  // this works

Javascript代码:http://codyhouse.co/demo/faq-template/js/main.js

风格:http://codyhouse.co/demo/faq-template/css/style.css

2 个答案:

答案 0 :(得分:0)

这似乎有几个问题。对我来说,当滚动事件触发时,一切都会发生。

试试这个:

$(document).ready(function(){
    $(window).scroll();
})

答案 1 :(得分:0)

快速破解,使用

if(window.location.hash) { 
    // if url contain '#' 
    // scroll down a few pixle
}

编辑:

很难在jsfiddle中解析这个,因为它不会让我玩#hash。

var url = 'http://example.com/test.html#hash';  
//you can get by using window.location.href
var hash = url.split('#')[1];
// this get the 1st hash variable     

if(hash) {
// if hash exist  
    $('html, body').animate({
           scrollTop: "5000px"
     }, 0);
// scroll down a little bit 
}
相关问题