简体   繁体   English

最大高度容器,内部有很高的固定位置容器

[英]Max height container with very tall fixed position container inside it

Having some trouble with a very basic CSS problem. 遇到一些非常基本的CSS问题。

I have a container that has a max-height of 655px. 我有一个容器,最大高度为655px。 Now to the very right of that container is a fixed position container (it must be fixed position due to what I'm doing). 现在,该容器的最右边是一个固定位置的容器(由于我在做什么,它必须处于固定位置)。 The fixed position container has an absurdly large height. 固定位置容器的高度非常大。

It needs that height because it will be filled with content, that you'll ultimately see by clicking buttons and by some javascript. 它需要这个高度,因为它将充满内容,最终您将通过单击按钮和一些JavaScript看到这些内容。 (changing the scrollTop) (更改scrollTop)

I'm not 100% sure what I'm doing wrong, but I basically need only 655px of the fixed position container to show. 我不是100%知道自己在做什么错,但是我基本上只需要655px的固定位置容器即可显示。 I'm not really sure why this doesn't work the way I have it setup. 我不太确定为什么这种设置方式不起作用。

Check out the JS fiddle here: http://jsfiddle.net/BG2bu/ 在此处查看JS小提琴: http//jsfiddle.net/BG2bu/

.tall {
background-color:blue;
position:absolute;
right:0px;
width:200px;
height:5000px;
}

I'm using this CSS to define the tall container. 我正在使用此CSS定义高个子容器。 And I know if I change the position to absolute, it will constrain to the max height of it's parent container. 而且我知道如果将位置更改为绝对位置,它将限制为其父容器的最大高度。 I really need this container to be fixed though for other reasons. 尽管出于其他原因,我确实需要修复此容器。 Is there any possible way to do this? 有什么可行的方法吗? Am I missing something simple here? 我在这里缺少简单的东西吗?

If this can be done with a JS/Jquery solution I'm definitely open to that. 如果可以使用JS / Jquery解决方案来做到这一点,那么我绝对会接受的。

Not sure this would be suitable for your needs but I've wrapped the .tall div with another container as position:fixed will not adhere to overflow:hidden in its container div. 不确定这是否适合您的需求,但我已经将.tall div用另一个容器包装了,因为position:fixed将不会坚持其容器div中的overflow:hidden

http://jsfiddle.net/3DZ53/ http://jsfiddle.net/3DZ53/

Hard to tell if this suits your need or not, but could you... 很难说这是否适合您的需求,但是您可以...

.tall {
    max-height: 655px;
    overflow: scroll / hidden;
}

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

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