【问题标题】:Why scrolling down in chrome is not working after increasing div height为什么在增加 div 高度后在 chrome 中向下滚动不起作用
【发布时间】:2016-12-01 10:35:59
【问题描述】:

我在这里找到了很多关于这个问题的答案,但在 Chrome 中没有任何效果,但它们在 Firefox 中有效..

我正在尝试使用 js/jQuery 增加 div 的高度。在 Chrome 中,它会增加高度,但我无法向下滚动。 这是我尝试做的。

function h() {
  document.getElementById('d').setAttribute("style", "height:1500px");
}
<button onclick="h()" class="btn btn-info">Select All videos</button>

<div id="d">
  Foo
</div>

我也尝试了 jQuery $("#d").css("height","1500px");,但我无法弄清楚为什么向下滚动不起作用。

【问题讨论】:

  • 您在上面显示的效果很好 - 正如您从我添加的用于演示您的代码的 sn-p 中看到的那样。您是否在父元素上设置了overflow: hidden?另外,检查控制台是否有错误
  • 如果正确且有效,您的代码会脱离上下文。 jsbin.com/ronotiqewi/edit?html,css,output
  • 不,没有这样的。
  • 我看到它在 Chrome 中正常工作。
  • 哇。是的,我也能看到。但是为什么我的浏览器看不到它?有什么想法吗?

标签: javascript


【解决方案1】:

我找到了解决方案。是其他一些javascript代码导致了这个问题,我删除了它们并尝试了它,它工作了,所以代码是完美的。

感谢您的帮助..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-13
    • 1970-01-01
    • 2018-08-11
    • 2014-12-10
    • 2011-07-08
    • 2018-05-28
    • 2019-01-03
    • 2011-10-02
    相关资源
    最近更新 更多