Inside the container block there are three blocks: left , main , right . The blocks have a fixed width, but their height depends on the filling of the main block, that is, on its height. The left and right blocks themselves are empty, which is what caused the problem.

 <div id="container"> <div id="left"></div> <div id="main">text</div> <div id="right"></div> </div> 

Styles:

 <style> #container{width:200px} #left{float:left;width:50px;height:100%} #right{float:right;width:50px;height:100%} #main{margin:0 50px} </style> 

With these styles, the left and right blocks are simply invisible. If these blocks are set to min-height , they do not acquire a height greater than this minimum height, ie the blocks remain at a fixed height:

alt text

How can you get rid of this problem and make the "dependence" of the height of the side blocks on the height of the middle block?

    2 answers 2

    Here you need to work with position: absolute - on the sides, any - for the container (but be sure to designate)

     <style> #container{width:220px;position: relative} #left{position:absolute;width:50px;height:100%;background:blue} #right{position:absolute; right:0px;width:50px;height:100%;background:gray} #main{margin:0 50px;background:red} </style> <div id="container"> <div id="left"></div> <div id="right"></div> <div id="main">много-много текста, и ещё больше <br /> </div> </div> 
    • Thanks, it turned out to be convenient and cross - browser - Crasher

    Why resort to absolute positioning again? This is not a panacea! can here

    Get acquainted with another method, in my opinion, more elegant.

    • Something like that looks too scary - Crasher