Skip to content Skip to sidebar Skip to footer

Css Button Rendering Issue On Internet Explorer Using Css Filter Gradient

For some reason, only the top half of a button appears in Internet Explorer. The button renders fine in Firefox, Chrome, and Safari. We are using 'filter:progid:DXImageTransform' t

Solution 1:

Couple of things:

1) I'd recommend trying out CSS3PIE, it allows you to use gradients etc and will have sorted out many issues that you might face.

2) IE9 doesn't have the filter support, so if you want it to work there you will need to use either an image, or a datauri of an SVG image like this:

background-image: url("data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%0A%20%20%20%20%20%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%20%20%20%20%20%20%20%20%20%3Cdefs%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3ClinearGradient%20id%3D%22grad%22%20x1%3D%220%22%20y1%3D%2250%25%22%20x2%3D%220%22%20y2%3D%22100%25%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cstop%20offset%3D%220%22%20stop-color%3D%22%23ff0000%22%20%2F%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3Cstop%20offset%3D%221%22%20stop-color%3D%22%23000000%22%20%2F%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%3C%2FlinearGradient%3E%0A%20%20%20%20%20%20%20%20%20%3C%2Fdefs%3E%0A%20%20%20%20%20%20%20%20%20%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%22100%25%22%20height%3D%22100%25%22%20style%3D%22fill%3Aurl%28%23grad%29%22%20%2F%3E%0A%20%20%20%20%3C%2Fsvg%3E%0A");

That's made by urlencoding an svg that looks like this:

<?xml version="1.0" encoding="utf-8"?><svgversion="1.1"xmlns="http://www.w3.org/2000/svg"><defs><linearGradientid="grad"x1="0"y1="50%"x2="0"y2="100%"><stopoffset="0"stop-color="#ff0000" /><stopoffset="1"stop-color="#000000" /></linearGradient></defs><rectx="0"y="0"width="100%"height="100%"style="fill:url(#grad)" /></svg>

That has the advantage of working in Opera as well.

This means you'd do the normal grad, then that, then the filter to cover modern browsers, IE9, Opera and IE8 and down.

At this point, you may decide to write a script that generates an image of a grad for you, like this one: http://www.bradshawenterprises.com/blog/2010/dynamically-drawing-gradients-with-php/

Post a Comment for "Css Button Rendering Issue On Internet Explorer Using Css Filter Gradient"