简体   繁体   English

滚动条在一些div上呈现但不在其他div上呈现[jScrollPane / jQuery]

[英]scrollbars rendering on some divs but not others [jScrollPane / jQuery]

I'm using the jScrollPane plugin to render scrollbars on some divs. 我正在使用jScrollPane插件来渲染某些div上的滚动条。 My problem is that one of the divs displays its scrollbars fine, whilst the other div not only does not display its' scrollbars, the content inside it is also messed with. 我的问题是其中一个div显示它的滚动条很好,而另一个div不仅没有显示它的'滚动条,它内部的内容也被搞乱了。

the content inside the div has been rearranged (all <p> at the top, then all <img> then all <h#> etc) and all line breaks and other formatting have been removed. div中的内容已经重新排列(所有<p>在顶部,然后所有<img>然后所有<h#>等)并且所有换行符和其他格式都已被删除。 I can't figure out why this would be happening because both divs have exactly the same properties set in the stylesheet for the page. 我无法弄清楚为什么会发生这种情况,因为两个div在页面样式表中设置了完全相同的属性。

Is there a common cause of this kind of thing? 这种事情有共同的原因吗? I initially thought it might be something to do with the misbehaving div containing images so I tried enabling autoReinitialise but I still experience the same problem. 我最初认为它可能与包含图像的行为不端的div有关,所以我尝试启用autoReinitialise但我仍然遇到同样的问题。

edit, for more content: 编辑,了解更多内容:

the div that is misbehaving is called content . 行为不端的div称为content the div that works is called comments . 有效的div称为comments the css for the scrollbars is identical for each - they both reference the same stylesheet. 滚动条的css对于每个都是相同的 - 它们都引用相同的样式表。

js : js

$(window).load(function() {

         $("#content").jScrollPane(
                    {
                        autoReinitialise: true
                    }
                );

});
$(document).ready(function(){

    //scroll barzzz
    $("#comments").jScrollPane();
});

css : css

#content  {
        font-family: Helvetica, Arial, Sans-serif;
        text-align: justify;
        width: 95%;
        height: 350px;
        background-color: #fff;
        padding: 20px;
        opacity: 0.0;
        margin: 10px;
        overflow:auto;
        border-radius: 15px;
        border: solid 1px #eee;

    }
#comments {
        font-family:      Helvetica, Arial, Sans-serif;
        height: 300px;
        width: 90%;
        background-color: #fff;
        padding: 10px 10px 10px 10px;
        opacity: 0.0;
        margin: 10px;
        border-radius: 15px;
        overflow:auto;
        border: solid 1px #eee;

    }

I had a similar problem and it was solved by putting my content inside a <p> -tag. 我有一个类似的问题,它通过将我的内容放在<p> -tag中解决。 For some reason the jScrollPanel code stopped working when there was content inside the scrollable div that wasn't enclosed by a second block-tag like <p> or <h1> . 出于某种原因,当可滚动div内的内容未被第二个块标记(如<p><h1>包围时,jScrollPanel代码停止工作。

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

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