Mar 14

A New Way to Trigger hasLayout on Elements in Older Versions of IE?

I’ll be the first to admit that I haven’t given this too much thought, so I admit there could be some drawbacks I haven’t considered, but I thought I’d throw the idea out there and see what my readers think.

Suppose we have an element that, for design and flexibility purposes, has no set width, and no set height. But obviously it has content, so in most browsers it expands to hold its content. We want that element to have a linear gradient background using CSS3, and we add a Microsoft proprietary filter to cover all versions of IE.

Here’s the element, demoed live on the page, with the aforementioned characteristics:

I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout. I can haz layout.

In every browser except IE6 and IE7, the above box should appear just fine with its gradient background. In IE6 and IE7, it looks like this: Continue reading