简体   繁体   English

使用jQuery滚动条允许height%

[英]Allow height% with jQuery scrollbar

I am using the Malihu custom content scroller with automatic scrolling. 我正在使用Malihu自定义内容滚动条和自动滚动条。 So far, I basically am experimenting with it. 到目前为止,我基本上已经在尝试它。 I noticed when I take the height of the scrolling div and use a percentage instead of a fixed amount in px, it expands the div the entire height of the scroll area (off the screen). 我注意到当我使用滚动div的高度并使用百分比而不是px中的固定量时,它会将div扩展到整个滚动区域的高度(在屏幕外)。

I'm literally just taking the code from this GitHub location then opening the file "auto_scrolling_example.html". 我实际上只是从GitHub位置获取代码,然后打开文件“ auto_scrolling_example.html”。

Then in the <style> section of the header, I'm simply changing .content: height:500px to .content: height:50% . 然后在标题的<style>部分中,我只是将.content: height:500px更改为.content: height:50%

Does anyone know why this doesn't work and/or have a good workaround for it? 有谁知道为什么这不起作用和/或有一个好的解决方法?

When you specify the height or width as a percentage, that's a percentage with respect to the element's parent. 当您将高度或宽度指定为百分比时,这是相对于元素父级的百分比。

If the parent doesn't have any height or width inner children will not work in percentage. 如果父级没有任何高度或宽度,则内部子级将无法按百分比工作。

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

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