简体   繁体   English

相对于子div水平滚动滚动父div

[英]Scrolling the parent div with respect to the child div horizontal scroll

I have following HTML code: 我有以下HTML代码:

<div style="height: auto; width: 400px; overflow: hidden;" id= "parent">
   //dynamic content which makes width of the parent to overflow
   <div style= "height: 200; width: 400px; overflow: auto;" id= "child">
   // dynamic content which makes width of the child div to overflow horizontally and vertically
   </div>
</div>

Is there any way, I can scroll the parent div Horizontally while I am scrolling the child div? 有什么办法可以在滚动子div时水平滚动父div? Actually, I am trying to freeze the headings(the content of the parent div) and want a scroll for the data (Content of the child div). 实际上,我正在尝试冻结标题(父div的内容),并希望滚动显示数据(子div的内容)。 Any help would be deeply appreciated. 任何帮助将不胜感激。

Thanks 谢谢

There is a CSS white-space:nowrap attribute that may work. 有一个CSS white-space:nowrap属性可能起作用。

An issue you may be running into is that most HTML text will line wrap by default. 您可能会遇到的一个问题是,默认情况下,大多数HTML文本都会自动换行。 You may have to use the <pre> or <code> tags to get the horizontal scrolling inside the parent div without line breaks if that is what you are looking for. 您可能需要使用<pre><code>标记来获取父div内的水平滚动,而无需换行符(如果要查找的话)。

Or to get the freeze pane effect your comment says you are looking for, just use a separate div for the header and content panes. 要获得冻结窗格的效果,您的评论说您正在寻找,只需对标题和内容窗格使用单独的div。

<div id="container">
    <div id="header"></div>
    <div id="info"></div>
</div>

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

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