There is a main block with a specified height in pixels. There are 3 indoor units:

  • top - should scale by content and compress the middle block
  • middle - must be with a scrollbar appearing (if there is not enough space for content)
  • buttom - fixed pixel height

How to make the main block NOT stretch , but remain the same height, at the same time the top block squeeze the middle block with its contents ?

#main{ height:200px !important; width:100px; background:blue; } #top{ background:green; } #middle{ background:red; height:100%; overflow: auto; } #buttom{ background:blue; height:50px; bottom:0 } <div id="main"> <div id="top">ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚</div> <div id="middle">ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚ </div> <div id="buttom">ะขะตะบัั‚ ั‚ะตะบัั‚ ั‚ะตะบัั‚</div> </div> 

Any suggestions on how to do this? http://jsfiddle.net/5fCcy/3/

  • one
    Immediately I will note: height 100% - the element will take the height of the parent. And if the parent has 200px, then I think itโ€™s clear. The second, which is not clear, to what extent can the middle block be reduced? - mccrush
  • until completely shut. Well, or at least some, any. About height, yes, I understand that the height of the parent. Just made for clarity of the problem. - internet4ik

1 answer 1

CSS has a big problem with height, so I would not suffer and decide through JS . The script can be simplified, I just wrote it for clarity. And users with disabled JS let them watch a simplified version of the site :)

  • Thanks, users with disabled js do not interest me =) Anyway, for the time being, I'm waiting, can someone on css tell me how to do it. Interesting for myself already. - internet4ik