简体   繁体   English

在另一个div中滚动div

[英]Scrolling div in another div

I want to add scrolling to the second part, it is "chat-messages" div in "chat-bar" div. 我想将滚动添加到第二部分,它是“聊天栏” div中的“聊天消息” div。 I want JUST this "chat-messages" to make scrollable, leaving rest of the site with no any scrool. 我只想使此“聊天消息”可滚动,而在网站的其余部分不留任何可可。 At this moment I have to scroll the whole site to see "input-row" div. 此时,我必须滚动整个站点才能看到“ input-row” div。 It's quite working when i set overflow: auto to the "chat-bar" but then whole input-row is also included in scrolling. 当我将overflow: auto设置为“ overflow: auto ”时,它非常有效overflow: auto设置为“聊天栏”,但是整个input-row也包含在滚动中。 Please give me best css/html option how to resolve this problem, or give me simple javascript library. 请给我最好的css / html选项如何解决此问题,或者给我简单的javascript库。

jsfiddle link: jsfiddle链接:

jsfiddle.net/o9vmfgpx/3

edit: I made it working, but in some hacky way. 编辑:我使它工作,但以某种变态的方式。

.chat-messages {
    overflow-y: scroll;
    -ms-overflow-style: none;
}
.chat-messages::-webkit-scrollbar {
    display: none;
}

@-moz-document url-prefix() {
    .chat-messages {
        right: -5%;
        padding-right: 3%;
    }
}

Works on latest version of IE, EDGE, Chrome, Firefox and Opera (as 10.14.2016) 适用于IE,EDGE,Chrome,Firefox和Opera的最新版本(截至10.14.2016)

This should work. 这应该工作。

body {
      overflow:hidden;
}
.chat-messages {
       overflow:scroll !important;
}

Try this. 尝试这个。

.input-row {
    position: fixed;
    bottom: 10px;
    left: 10px;
}

Try adding the below css? 尝试添加以下CSS?

.chat-messages {
  height:200px;
  overflow:scroll;
}

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

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