简体   繁体   English

在div中隐藏滚动条

[英]Hiding scrollbar in div

Hello budding web enthusiasts. 您好,新兴的网络爱好者。 I am afraid that I am in quite a pickle and need a helping hand. 恐怕我很腌制,需要帮助。 In a current web project, I ran into a sour wall. 在当前的Web项目中,我遇到了麻烦。 This here is the code. 这是代码。 Take a gander. a一g。 From the code, it does exactly what I want. 从代码来看,它确实可以实现我想要的功能。 But here is the problem . 但这是问题所在 There are scrollbars on the div. div上有滚动条。 I dont want any scrollbars on my divs. 我不想在我的div上有任何滚动条。 I tried overflow-y:scroll; 我尝试了溢流-y:滚动; and got rid of the horizontal scrollbar but the vertical scrollbar is still there. 并摆脱了水平滚动条,但垂直滚动条仍然存在。 I tried a lot and searched for it but to no avail. 我尝试了很多并进行了搜索,但无济于事。 How can I get rid of both the vertical and horizontal scrollbars in my divs with it still bieng able to scroll. 我如何摆脱div中的垂直和水平滚动条,并且仍然能够滚动。

edit : I also need it to be cross browser functional. 编辑:我还需要它具有跨浏览器的功能。 not only chrome. 不仅是铬。

HTML HTML

<div id="content">
    <div id="left">
        <div class="richyPhoto"> </div>
    </div>

    <div id="right">
    </div>
</div>

CSS CSS

body {
    overflow:hidden;
}
#content, html, body {
    height: 100%;
    width:100%;
    margin:0;
    padding:0;
}
#left {
    float: left;
    width: 50%;
    background: red;
    height: 100%;
    overflow: scroll;
}
#right {
    float: left;
    width: 50%;
    background: blue;
    height: 100%;
    overflow: scroll;
}

I would use this technique: 我会使用这种技术:

#parent{
height: 100%;
width: 100%;
overflow: hidden;
}

#child{
width: 100%;
height: 100%;
overflow: auto;
padding-right: 15px; /* Increase this value for cross-browser compatibility */
}

Here's a working Fiddle: http://jsfiddle.net/5GCsJ/954/ 这是工作中的小提琴: http : //jsfiddle.net/5GCsJ/954/

Here is a way to do it: HTML 这是一种实现方法:HTML

<div id="content">
    <div id="left">
        <div class="richyPhoto"> </div>
    </div>

    <div id="right">
       <div class="richyPhoto2"> </div>
    </div>
</div>

CSS CSS

body {
    overflow:hidden;
}
#content, html, body {
    height: 100%;
    width:100%;
    margin:0;
    padding:0;
}
#left {
    float: left;
    width: 50%;
    background: red;
    height: 100%;
    overflow: hidden;
}
.richyPhoto {
    width: 100%;
    height: 99%;
    border: 1px solid red;
    overflow: auto;
    padding-right: 15px;
}
#right {
    float: left;
    width: 50%;
    background: blue;
    height: 100%;
    overflow: hidden;
}
.richyPhoto2 {
    width: 100%;
    height: 99%;
    border: 1px solid blue;
    overflow: auto;
    padding-right: 15px;
}

Working Fiddle link: No scrollbars scroll 工作小提琴链接: 无滚动条滚动

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

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