Hello boys and girls!
First, a small introduction:
<!doctype html> <html> <head> <style> body, div { padding:1%; } body { background-color:red; } div.div1 { height:50%; min-height:200px; background-color:green; width:100%; position:absolute; } div.div2 { float:left; height:50%; background-color:red; } div.div3 { float:left; height:40%; background-color:grey; } img.img1 { float:left; height:96%; background-color:black; width:100px } img.img2 { float:left; height:50%; width:100px; background-color:black; } </style> </head> <body style="background-color:red;"> <div class="div1"> <div class="div2"> <img src="" class="img1" /> </div> <img src="" class="img2" /> <div class="div3"></div> </div> </body> </html>
You can see here
In short: there is a main div, from which the other values in percent should be calculated. At the same time, this height div must not be less than a certain value. Wrote, did, check:
- Mozila - everything works
- Opera - values are calculated correctly, but for some reason the screen is redrawn only if the page is updated. When you change the width of the window, it does almost what you need (by updating the screen we see that it was still a little something wrong), but somehow it jumps (you lead - it is sharply more than necessary and immediately the norm). When you change the height of the window - it behaves somehow unpredictable: it does not increase, decreases sharply and irregularly (that is, it does not decrease until a certain moment, then a sharp decrease).
- IE 9 - everything works
- IE 8, Safari - problems appear - divs behave as they should, but img behaves strangely - as far as I understand, the values are calculated not from the main div, but from the body, i.e. div'y one day cease to decrease, but img continues to successfully do this ...
Decision (?):
At the main div'a set position: static. Other problems appear:
IE8, Opera, Safari, Mozilla - the calculation is carried out from the body, i.e. if its height is less than the min-height of the main div, then, respectively, the remaining elements will have far from the height that is needed. In a real project, the contents of the main div are fully specified in percent, i.e. all elements retain their position relative to each other, thus the appearance is kept as it should ... Well, or almost ... the min-height of the main div is not taken into account, and this is not what is required ...
What could be the reasons for such a strange behavior of Safari in the first case and why is the min-height ignored in the second? And how it is ignored - only if it is necessary to calculate the height values of the internal elements, the div itself maintains its height equal to the min-height.