Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table cell loses border when css gradient filter is applied in IE8

I found the css border on the table cell is lost when applying css gradient filter at the same time. It seems that the gradient effect overrides the border.

Is it a browser bug or am I missing something here?

The style is defined like this:

.c7 {
    color: #000000;
    filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#c0c0c0',EndColorStr='#f0f0f0'); 
    border: #000000 1px solid;
    width: 100px;
    height: 30px;
}

[Update] You could apply an opacity filter and reduce it from 100 to 1, and you can see how border emerges gradually. It confirms my guess that the gradient effect shows over the border.

like image 916
Chris Avatar asked Aug 12 '10 06:08

Chris


5 Answers

Applying this also works:

position: relative;
z-index: -1;
like image 167
frizz Avatar answered Nov 15 '22 01:11

frizz


I've found a fix but you may not like it...

If you render in IE in quirks mode the border renders fine, it is only obscured if you're using compatibility mode. Compare these two pages in IE8:

  • With a DOCTYPE declaration


    • (source: boogdesign.com)
  • Without a DOCTYPE declaration


    • (source: boogdesign.com)

What also works is clicking the compatibility view button, but my attempts to get the same results with the compatibility mode meta tags were unsuccessful. I tried using box-sizing, but also with no success. I conclude the only way to get it to work as you want is to force IE into quirks mode, but that may create so many other issues for layout that you may be better off just adding a wrapper element to attach your gradient background to.

like image 33
robertc Avatar answered Nov 15 '22 01:11

robertc


Use a DIV to contain the content in each cell. Apply the gradient to the DIV and put the border on the cell. The gradient will be restricted to the DIV and will not overwrite the border.

http://jsfiddle.net/WWCaj/1/

like image 6
Stormalong Avatar answered Nov 15 '22 00:11

Stormalong


After trying lots of fixes I've come to the conclusion that its simply not worth trying to use filter CSS. A quote from @mdo who's behind the Twitter bootstrap css:

Filters are dangerous business in IE, especially 7 & 8. I'd rather not include those because it'd be huge performance losses for folks who overuse them.

Problems I hit applying css to td elements:

  • The position: relative only works for IE9, not IE8
  • The z-index: -1 doesn't work on td elements
  • If you do have a filter then you have to turn it off for hovering
  • My table looked better having the borders than having the gradient on the table cells
like image 3
icc97 Avatar answered Nov 14 '22 23:11

icc97


use position: relative !important;

Its work fine...

like image 1
Siddhesh Jorwekar Avatar answered Nov 15 '22 01:11

Siddhesh Jorwekar