Why certain DOCTYPE declarations cause 100%-height tables and divs to stop working?

前端 未结 3 2006
无人及你
无人及你 2020-12-01 23:56

It seems to me that some DOCTYPE declarations in IE (6-8) may cause the browser to ignore height=\"100%\" on tables and divs (style=\"height:

3条回答
  •  难免孤独
    2020-12-02 00:30

    1. Because ancient browsers had odd, inconsistent behavior and browsers treat Doctypes like an intelligence test to see if the author is writing code to the standards or to what they learned from W3Schools a decade ago. If you have height: 100% and the height of the parent element is auto then 100% means auto.

    2. Generally, you don't. It screams "layout table". That said, set heights or minimum heights on the html and body elements. There are other techniques, but I don't have a handy link at the moment as, oddly, I've never been in a position where I needed the technique.

    3. It is what browsers are supposed to do, so …

    4. Well, I am answering this question …

提交回复
热议问题