views:

363

answers:

3

I'm using the internet explorer gradient filter in my CSS.

It was all going well until I noticed that images that are supposed to extend beyond their containers overflow:visible; are getting clipped as though the container was set to overflow:hidden;

I have no idea why this would happen, or how to fix it. Can anyone help?

I'm looking at it in IE8 and IE7

This is the css causing the issue, when I comment it out, no more bug:

.box{
filter:  progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#b4cfe9', endColorstr='#e4eefc'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#b4cfe9', endColorstr='#e4eefc')"; /* IE8 */
}
A: 

I know this doesn't answer your question in particular, but consider your audience. Are they all just Internet Explorer users, or do they represent natural internet user proportions? If they are not all just IE users (maybe in a corporate/education network) then consider using only the standards-compliant methods, and allowing the application/site to degrade gracefully to a browser that doesn't support it, like IE.

Now, for your question. The reason why it's not working as you expected is that the box does not extend to the end of content, even when overflow is visible. The content simply 'walks' outside the box, but this doesn't make the box bigger. There is no way you can get the box to extend to fit the content, except for not setting the width and/or height properties fixed. In fact, IE had a bug in which instead of overflowing out, the box did extend (this was a bug).

I can recommend one tip though; use min-<width/height> and max-<width/height> instead of width and/or height. They allow you flexible box sizing, with guided boundaries.

Delan Azabani
You're right, the first bit didn't answer my question. The second bit isn't right. I *want* my content to "walk outside the box" as you put it, the point is that it doesn't, and it only stops overflowing correctly when I apply the gradient filter.
David Meister
Then if so, my first paragraph applies as my opinion.
Delan Azabani
Continuing to use IE-proprietary methods only prolongs the life of the blasted thing.
Delan Azabani
Ignoring the requests of my clients only decreases the chances of future employment. Is your reluctance to help make the internet work as efficiently and neatly as possible for *users* of the internet because you won't or just because you can't and it's easier to be derisive than answer my question? I don't see how doing this is worse than including extra http requests for images of every gradient on the site.
David Meister
A: 

I'm having the same problem, did you find any way to solve it?

Tukler
yeah, sorta. I'll update the question to reflect what I discovered.
David Meister
+2  A: 

This works, although it's extra markup.

<div id="box_that_wants_a_gradient">
    <div class="gradient_background_1"></div>
    <div class="gradient_background_2"></div>

My content

</div>

There is a bonus to this tactic, as you can add multiple gradient boxes and set their heights/widths as a % of the parent, thus emulating the "colour stop" behaviour allowed in safari/moz.

For example:

<style>

#box_that_wants_a_gradient {
  position:relative;
  display:block;
  height:100px;
  width:100px}

.gradient_background_1 {
  position:absolute;
  height:20%;
  *cbf writing out microsoft filter code*;
  top:0;
  width:100%;
  left:0px}

.gradient_background_2 {
  position:absolute;
  height:80%;
  *still cbf writing out microsoft filter code*;
  top:20%;
  width:100%;
  left:0px}

</style>
David Meister
PS - the extra writing is heinous, I've gone back to images, for now.. hopefully chrome finishes off IE in the next few years.
David Meister