div不能滚动只有浏览器窗口有滚动条

发布于 2025-01-02 21:46:18 字数 4888 浏览 0 评论 0原文

左侧和右侧有很多文本,但无法彼此独立滚动,因为我必须滚动整个浏览器窗口。

在没有浏览器窗口滚动条的情况下,如何在左右 div 中滚动比垂直屏幕更长的文本?

http://jsfiddle.net/uFDK5/5/

CSS:

body {
     background-color:Yellow;   
    margin: 0;
    padding: 0;
    height:100%; 
    width:100%;
    font-size: .85em;
    font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif;
}

#DataGridButtonBar
{
    background-color:Fuchsia;     
}

#TreeButtonBar
{     
    width:200px;
    float:left;
    background-color:Maroon;    
}

#TreeWrapper{
   background-color:Aqua;    
   width:200px; 
   float:left;      
}

#DataGridWrapper{
     background-color:Silver; 
}

.clear
{
    clear:both;    
}

input button
{
    display:inline;    
}

HTML:

<div id="TreeButtonBar">

    <input type="button" value="Add Node" />
    <input type="button" value="Delete Node" />

</div>    

<div id="DataGridButtonBar">      
    <input type="button" value="Add row" />
    <input type="button" value="Delete row" />
</div>    

<div class="clear"></div>

<div id="TreeWrapper">
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>


<div id="DataGridWrapper">
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>

<div class="clear"></div>

The left and the right side has much text but can not be scrolled independendly from each other because I have to scroll the whole browser window.

How can I scroll text longer than the vertical screen in the left and right div without having a browser window scrollbar?

http://jsfiddle.net/uFDK5/5/

CSS:

body {
     background-color:Yellow;   
    margin: 0;
    padding: 0;
    height:100%; 
    width:100%;
    font-size: .85em;
    font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif;
}

#DataGridButtonBar
{
    background-color:Fuchsia;     
}

#TreeButtonBar
{     
    width:200px;
    float:left;
    background-color:Maroon;    
}

#TreeWrapper{
   background-color:Aqua;    
   width:200px; 
   float:left;      
}

#DataGridWrapper{
     background-color:Silver; 
}

.clear
{
    clear:both;    
}

input button
{
    display:inline;    
}

HTML:

<div id="TreeButtonBar">

    <input type="button" value="Add Node" />
    <input type="button" value="Delete Node" />

</div>    

<div id="DataGridButtonBar">      
    <input type="button" value="Add row" />
    <input type="button" value="Delete row" />
</div>    

<div class="clear"></div>

<div id="TreeWrapper">
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>


<div id="DataGridWrapper">
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
     Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</div>

<div class="clear"></div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

念﹏祤嫣 2025-01-09 21:46:18

尝试:

#TreeWrapper{
    background-color: aqua;    
    width: 200px; 
    float: left;      
    position: fixed;
    left: 0px;
    top: 20px;
    bottom: 0px;
    overflow-y: auto;
    overflow-x: hidden;
}

#DataGridWrapper{
    background-color: silver;
    position: fixed;
    left: 200px;
    top: 20px;
    bottom: 0px;
    overflow-y: auto;
    overflow-x: hidden;
}

Try:

#TreeWrapper{
    background-color: aqua;    
    width: 200px; 
    float: left;      
    position: fixed;
    left: 0px;
    top: 20px;
    bottom: 0px;
    overflow-y: auto;
    overflow-x: hidden;
}

#DataGridWrapper{
    background-color: silver;
    position: fixed;
    left: 200px;
    top: 20px;
    bottom: 0px;
    overflow-y: auto;
    overflow-x: hidden;
}
风为裳 2025-01-09 21:46:18

这是可行的,但是您可能想调整宽度的高度和宽度......

body {
     background-color:Yellow;   
    margin: 0;
    padding: 0;
    height:100%;
    width:100%;
    font-size: .85em;
    font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif;
}

#DataGridButtonBar
{
    background-color:Fuchsia;     
}

#TreeButtonBar
{     
    width:200px;
    float:left;
    background-color:Maroon;

}

#TreeWrapper{
   background-color:Aqua;    
   width:200px;
   height:400px;
   float:left;
   overflow:scroll;    
}

#DataGridWrapper{
     background-color:Silver;
     width:300px;
     height:400px;
     float:left;
     overflow:scroll;
}

.clear
{
    clear:both;    
}

input button
{
    display:inline;    
}

This works, however you might want to fiddle width the height and widths...

body {
     background-color:Yellow;   
    margin: 0;
    padding: 0;
    height:100%;
    width:100%;
    font-size: .85em;
    font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif;
}

#DataGridButtonBar
{
    background-color:Fuchsia;     
}

#TreeButtonBar
{     
    width:200px;
    float:left;
    background-color:Maroon;

}

#TreeWrapper{
   background-color:Aqua;    
   width:200px;
   height:400px;
   float:left;
   overflow:scroll;    
}

#DataGridWrapper{
     background-color:Silver;
     width:300px;
     height:400px;
     float:left;
     overflow:scroll;
}

.clear
{
    clear:both;    
}

input button
{
    display:inline;    
}
波浪屿的海角声 2025-01-09 21:46:18

您可以在两个 div 元素上使用 overflow:scroll; CSS 属性来实现此目的。所以在你的情况下它将是:

#TreeWrapper, #DataGridWrapper {
   overflow: scroll; 
}

You use the overflow: scroll; CSS property on both you div-elements to accomplish that. So in you case it would be:

#TreeWrapper, #DataGridWrapper {
   overflow: scroll; 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文