chrome中的jScrollPane 2.0高度问题

发布于 2024-09-25 01:52:42 字数 1006 浏览 8 评论 0原文

我在绝对定位的 div 中使用带有滚动窗格类(高度 100%)的 div。滚动窗格 div 首先包含一些文本,然后是图像,最后再包含一些文本。图像高度设置为 200px。 问题是!如果我在 Chrome(最新版本)中查看滚动窗格,有时可以滚动完整内容,有时在浏览器中刷新网站后则不能滚动。不意味着我只能看到第二个文本的一部分,而不能看到更多。所以实际的滚动高度会缩小。如果我再次刷新,我也许能够再次看到一切都完成了,依此类推。每次刷新浏览器时它都会改变。它只发生在 Chrome 中。

知道我可以做什么来避免这种行为吗?谢谢......

更新 它确实与导入(js 和 css)在标头中的排列方式有关。你是对的,CSS 必须在 jscrollPane js 之前导入,但这也意味着图像高度需要来自 CSS 样式表之一。您无法在标记中的图像标签内定义高度。我的解决方案是在我的样式表中创建一个类,即 img200(代表 200px 的高度),这就成功了。 因此,要使其在 Chrome 或更好的 webkit 浏览器中正常工作,需要做什么: 在样式表中为滚动窗格中使用的图像设置图像高度类别。 之前包括你的样式表!!!! jScrollPane 的 javascript。 将特殊高度等级添加到包含到 jScrollPane 的所有图片 就是这样。再次感谢您的快速答复。非常酷。

最终解决方案更新!!!!!!!!!
如果 jScrollPane 区域内有图片,则必须确保满足以下条件,以便在 Webkit 浏览器(例如 Chrome 或 Safari)中良好地显示它们。否则会导致高度问题,并且只有部分内容可见。
这是你必须做的:
确保 css 样式表和 jScrollPane javascript 文件的排列正确。 jScrollPane javascript 文件需要遵循您的 css 样式表,而不是相反!此外,您还必须为 jScrollPane 区域中包含的每个图像添加高度。您可以通过创建 css 类来完成此操作,也可以将尺寸作为属性直接添加到 html 标记中的 img。
如果你牢记这一点,它就会成功。

I am using a div with class scroll-pane (height 100%) within an absolute positioned div. The scroll-pane div contains some text first, followed by an image and followed by some text again. The image height is set to 200px.
Problem is! If I view the scrollpane in Chrome (latest Version) I sometimes can scroll the complete content and sometimes, after refreshing the site in the browser, not. Not does mean that I can only see a part of the second text and not more. So the actual scrolling height shrinks. If I refresh again I might be able to see it all complete again and so on. It changes every time I refresh the browser. It only happens in Chrome.

Any idea what I can do to avoid that behavior? Thanks.....

UPDATE
It really got something to do with how the imports (js and css) are lined up in the header. You are right, the css got to be imported before the jscrollPane js but that also means that the image height need to come from one of the css stylesheets. You can not define the height right within the image tag in your markup. My solution was to create a class, for i.e. img200 (representing a height of 200px) in my stylesheet and that made the trick.
So here again what need to be done to make it work in Chrome or better webkit Browsers in general:
Set up a image height class in your stylesheet for images that are used within a scrollPane.
Include your stylesheet before!!!!! the javascript for jScrollPane.
Add the special height class to all pictures you include to a jScrollPane
That was it. Thanks again for your fast answer. Very cool.

FINAL SOLUTION UPDATE!!!!!!!!!
If you have pictures within a jScrollPane area you have to make sure the following in order to have it all displayed well in webkit browser, like Chrome or Safari. Otherwise it will cause height problems and only a part of your content will be visible.
This is what you have to do:
Make sure the line up of your css stylesheets and the jScrollPane javascript file is correct. The jScrollPane javascript file need to follow your css stylesheets and not the other way around! Also you have to add a height to each image that is included in the jScrollPane area. You can do this either by creating a css class or you can add the dimension as an attribute directly to the img in your html markup.
If you keep that in mind it will do the trick.

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

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

发布评论

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

评论(4

如梦 2024-10-02 01:52:42

您也在 Safari 中测试过吗?这听起来像是当 javascript 包含在文档头部的 CSS 之前时 Webkit 中出现的问题:
http://jscrollpane.kelvinluck.com/faqs.html#webkit-broken

如果这不是原因,那么可能与滚动窗格中有图像有关。您需要包含图像的宽度和高度(请参阅 http://jscrollpane.kelvinluck.com/image2 .html)或自动重新初始化窗格(请参阅 http://jscrollpane.kelvinluck.com/image。 html)。

希望它有帮助:)

Did you also test in Safari? This sounds like an issue that occurs in Webkit when the javascript is included before the CSS in the head of the document:
http://jscrollpane.kelvinluck.com/faqs.html#webkit-broken

If that isn't the cause then it might be something related to the fact that you have an image in your scrollpane. You need to either include the width and height of the image (see http://jscrollpane.kelvinluck.com/image2.html) or autoReinitialise the pane (see http://jscrollpane.kelvinluck.com/image.html).

Hope it helps :)

初心 2024-10-02 01:52:42

$(window).load 中调用 jscrollpane,而不是 $(document).ready

give the call to jscrollpane in $(window).load instead of $(document).ready

等数载,海棠开 2024-10-02 01:52:42

我还发现,向 .scroll-pane 添加行高的 css 规则可以解决我的高度问题。

例如:

.scroll-pane {line-height: 1;}

或您的内容可能需要的任何行高。

我还发现,如果您使用@font-face,jscrollpane可能会在字体正确加载之前进行高度计算,因此计算错误。我通过添加设置解决了这个问题:

autoReinitialise: true

它在计时器上运行,但请谨慎使用。

I have also discovered that adding a css rule to .scroll-pane for line-height solves my height issues.

For example:

.scroll-pane {line-height: 1;}

or whatever line height your content may need.

I also discovered that if you use @font-face, jscrollpane may do the height calculation before your font has properly loaded, and therefore miscalculate. I fixed this by adding the setting:

autoReinitialise: true

It runs on a timer though so use thoughtfully.

_畞蕅 2024-10-02 01:52:42

如果 jScrollPane div 区域内有图像,只需定义其宽度和高度。

<div class="scroll-pane">
<img src="image.jpg" alt="" width="300" height="50" />
</div>

这将修复 jScrollPane 的 webkit 错误。哦,当然是在 JS 之前加载 CSS

If you have image inside your jScrollPane div area, simply define its width and height.

<div class="scroll-pane">
<img src="image.jpg" alt="" width="300" height="50" />
</div>

That will fix the jScrollPane's webkit bug. Oh and of course load the CSS before JS

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