IE6 CSS display:table fix?

后端 未结 2 459
清酒与你
清酒与你 2021-01-29 04:44


I\'m working on a web app... unfortunately it has to work with the worst piece of software ever written, yes ie6.

I really like the CSS display:table a

2条回答
  •  不要未来只要你来
    2021-01-29 05:18

    Sorry. There isn't a fix to make IE6 support CSS display:table. The only way to acheive this layout in IE6 is to actually use

    elements.

    First question: do you really need to support IE6? If you can simply drop support for it, you'll solve yourself a whole ton of problems, including this one. Current global usage of IE6 is below 3%, and even lower in most developed countries.

    If you do still need to support IE6, then your most obvious solution is simply to swallow your semantic markup pride and just use a

    tag.

    As described by @Tom, the next best solution is to write your layout using display:inline-block;.

    inline-block allows you to define your elements as blocks, but still keep them in the text flow (kinda the way the tag works by default). If you combine this with fixed element widths, and wapper divs around rows, you could acheive something similar to a table, although it may be hard to get it to expand dynamically with the page width.

    The one big "gotcha" bug around this is that inline-block only works in IE6/7 for elements that have a default style of display:inline. In other words, it works for a but not for a

    . Not a disaster, but something to be aware of, especially since you're specifically asking about IE6 support. Other than that, the good news is that you should be able to get away with using display:inline-block without any other hacks or work-arounds.

    提交回复
    热议问题