简体   繁体   English

jQuery ScrollTo无法与高度和宽度一起使用100%

[英]JQuery ScrollTo not working with Height and Width 100%

I have seen this question asked on here before but with no working answers, also I imagine my problem is slightly different. 我之前曾在这里看到过这个问题,但没有有效的答案,我也想像我的问题会略有不同。

I have got quite a strange issue which I have been trying to work out, I am fairly sure I have not structured my css correctly but am having issues finding out where. 我遇到了一个很奇怪的问题,我一直在努力解决,我相当确定我没有正确构造CSS,但是发现问题出在哪里。

If you look at the following template in jsfiddle (ignore broken images) 如果您在jsfiddle中查看以下模板(忽略损坏的图像)

JSFIDDLE LINK JSFIDDLE链接

The height and width of the body is not scrolling, the scrollbar does appear down the right side but is unscrollable (am using a custom scrollbar). 主体的高度和宽度不滚动,滚动条确实出现在右侧下方,但是不可滚动(使用自定义滚动条)。 I realise this is to do with the body not inheriting a height most likely due to my floating div's. 我意识到这与身体没有继承最有可能归因于我的浮动div的身高有关。

I have been playing around with a clearfix div which I am still trying to make work, understandably if I add 我一直在玩一个clearfix div,我仍然在努力使之工作,如果我添加的话,这是可以理解的

height: 100%;
width: 100%;

to my css for my body class the scroll will work, however if I do this the JQuery ScrollTo stops working 到我的身体类的CSS滚动将工作,但是如果我这样做,则JQuery ScrollTo停止工作

I have put the anchor-link which does the scrollto in the top of this JSFIDDLE (it is also in the above fiddle but is not visible on the page and scrolling is broken) 我已经把anchor-link它确实在这个顶部scrollto 的jsfiddle (它也是上述小提琴,但不是在网页上显示和滚动被打破)

Understandably I need to clean up my code, but any advice on how I can get out of this situation would be just awesome! 可以理解,我需要清理代码,但是关于如何摆脱这种情况的任何建议都很棒!

Please let me know if I have not explained very well Thanks, Simon 如果我的讲解不够好,请告诉我,谢谢,西蒙

Wow I was being a giant numpty, slightly embarrassing but found the following in the middle of my css: 哇,我真是个笨蛋,有点尴尬,但是在CSS中间发现了以下内容:

html {
    overflow: hidden;
    height: 100%;
}

This is certainly what was causing the problem, issue solved! 这肯定是造成问题的原因,问题已解决!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM