39 out of 62 rated this helpful - Rate this topic

Gradient Filter

This topic documents a feature of Visual Filters and Transitions, which is deprecated as of Windows Internet Explorer 9.

Displays a color gradient between the object's background and content.

Syntax

HTML
<ELEMENT STYLE=
"filter:progid:DXImageTransform.Microsoft.Gradient(sProperties)"
... >
Internet Explorer 5.5 or later
Scripting
object .style.filter =
"progid:DXImageTransform.Microsoft.Gradient(sProperties)"
Internet Explorer 5.5 or later

Possible Values

sProperties String that specifies one or more properties exposed by the filter.

Members Table

The following table lists the members exposed by the Gradient object.

Attributes/Properties
Attribute Property Description
enabled Enabled

Sets or retrieves a value that indicates whether the filter is enabled.

EndColor

Sets or retrieves the final opaque color for a gradient surface.

EndColorStr

Sets or retrieves the final color for a gradient surface.

GradientType

Sets or retrieves the orientation of the gradient.

StartColor

Sets or retrieves the initial opaque color for a gradient surface.

startColorStr StartColorStr

Sets or retrieves the initial color for a gradient surface.

Remarks

When revealed by a transition, any text that covers a Gradient procedural surface is initially exposed as transparent. After the transition has finished, the text is updated to the applicable color.

The object that the filter is applied to must have layout before the filter effect will display. You can give the object layout by setting the height or width property, setting the position property to absolute, setting the writingMode property to tb-rl, or setting the contentEditable property to true.

You can assign multiple filters or transitions to an object by declaring each in the filter property of the object. The following div declaration assigns two filters and a Wheel transition to a div element.


<DIV STYLE="width:100%; filter:
    progid:DXImageTransform.Microsoft.MotionBlur(strength=13, direction=310)
    progid:DXImageTransform.Microsoft.Blur(pixelradius=2)
    progid:DXImageTransform.Microsoft.Wheel(duration=3);">
        Blurry text with smudge of gray.</div>     
When multiple filters are applied to an object, each filter is processed in source order, with the exception of procedural surfaces, which are computed first. To emphasize a filter's effect, place it last in source order or on the object's parent. Always place transitions last in source order.

Examples

The following example shows the effects of this filter when its properties are modified.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/filter/gradient.htm

This example shows how the text is unaffected by the gradient behind it.



<SCRIPT>

<!-- Toggle the Enabled property to toggle the gradient.  -->
function fnToggle(oObj) {
    if (oDiv.filters(0).enabled){
        oDiv.filters(0).enabled='false';
        oObj.innerText='Add Gradient';}
    else {                                                        
        oDiv.filters(0).enabled='true';
        oObj.innerText='Make Normal';}
}
</SCRIPT>

<font size="+5">
    <DIV ID="oDiv" STYLE="height:120px; color:green; filter: 
            progid:DXImageTransform.Microsoft.gradient(enabled='false',
                startColorstr=#550000FF, endColorstr=#55FFFF00)" >
        A simple gradient   
    </DIV>
</font>
<P>
<BUTTON onclick="fnToggle(this)">Add Gradient</BUTTON><BR/>

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/filter/shortSamples/gradientEX1.htm

Applies To

A, ABBR, ACRONYM, ADDRESS, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, CUSTOM, DD, DEL, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FONT, FORM, FRAME, hn, IFRAME, FRAMESET, I, INS, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, KBD, LABEL, LEGEND, LI, MARQUEE, MENU, NOBR, OL, OBJECT, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TEXTAREA, TH, TD, TT, U, UL, VAR, XMP

See Also

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Virtical Gradient Line's Using Gradient Filter?
I have been beating my head up against the wall trying to figure out how to produce Vertical Lines using a Gradient Filter. It's for a Background....

I have used CSS3 and it looks great, but that darn IE9, 8, 7 is giving me a hard time.... Help !
pls update ie9 to css3

this is outdated.
even ie9 does not support more than this linear left-to-right / top-to-bottom gradients, while chrome9 and ff4 have elliptical, radial, and Plateau Gradients.
pls add at least the Plateau Gradient to ie9.

Color your background with 7 gradients ...
Here is how you can put different colors in each screen corner + in the center + from top to bottom

Just make sure your document has <HTML><BODY> start and end elements and insert these functions:

//- set_background_corner(color, opacity, corner) -> set color in a corner (0 to 1 = top to bottom) (= 2 to 5) or in center (= 6); opacity is number from 1 to 100

// Set background colors
function set_background_corner(color, opacity, corner) {
 if (corner >= 0 && corner <= 6) {
  if (!color) { insert_bg_styles(undefined, 'bg_styles_' + corner); }
  else insert_bg_styles('background-color: ' + color + '; FILTER: Alpha(style='+ (corner==6?2:1) + ',opacity=' + opacity +
   ',finishOpacity=0' +
   (corner==0?',startX=50,finishX=50,startY=0,finishY=77); z-index: -998;' : // top
   (corner==1?',startX=50,finishX=50,startY=100,finishY=23); z-index: -999;' : // bottom
   (corner==2?',startX=0,finishX=23,startY=0,finishY=47); z-index: -995;' : // upper left
    (corner==3?',startX=100,finishX=77,startY=0,finishY=47); z-index: -994;' : // upper right
     (corner==4?',startX=100,finishX=77,startY=100,finishY=53); z-index: -997;' :
      (corner==5?',startX=0,finishX=23,startY=100,finishY=53); z-index: -996;' :
       '); z-index: -993;')))))), 'bg_styles_' + corner); // center
 }
}
// Set background colors
function insert_bg_styles(styles, id) {
 var divObj = document.getElementById(id);
 if (styles) {
  styles += ' position: absolute; top: 0px; left:0px; width: 100%; height:100%;';
  // Replace colors
  if (!divObj) {
   var newDivObj = document.createElement("DIV");
   newDivObj.id = id;
   newDivObj.style.cssText = styles;
   document.body.appendChild(newDivObj);
  }
  else divObj.style.cssText = styles;
 }
 // Remove element
 else if (divObj) divObj.parentNode.removeChild(divObj);
}

// AND finally here is some example of use:
set_background_corner('mistyrose', 100, 2);
set_background_corner('white', 100, 6);
set_background_corner('gold', 90, 3);
set_background_corner('moccasin', 100, 0);
set_background_corner('powderblue', 100, 1);
set_background_corner('palegreen', 100, 4);
set_background_corner('lavender', 100, 5);

enjoy!!
it's not working for me

i tried to use it in my site

look in the backgorund

it's not working

<a href="http://gamezat.dr3.net">العاب</a>

http://gamezat.dr3.net

Re: Gradient Font Problems

FYI, I have had luck getting my fonts to work by adding an invisible drop shadow:

filter: PROGID:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='white', EndColorStr='steelblue') PROGID:DXImageTransform.Microsoft.DropShadow(Color='white', OffX=0, OffY=0);

Doesn't Include IE8
This will cause other styles to not work in IE8!
Gradient filter brokes fonts!
Gradient filter brokes fonts
Gradient spoils the font appearance
Hi there
Gradient filter spoils fonts if the gradient is applied. Sympthoms: font Verdana turns into something urgly with juggy edges if I apply the gradient. Everithing is Ok if font size greater then ~13 pt. Bug?
And you guys displays here the only example where font size is huge. I believe, for the reason not to display this issue. Am I right?
Anyway, how to cope with it?
Thanks.
Gradient filter rendering bug on IE6 with SELECT controls

Is this a known bug?: I added a Gradient filter to the Body style of my web page. This displays fine on IE7 but on IE6 it screws up the page rendering when I scroll. Redrawing of the SELECT controls on the page seems to be the problem.

From the CSS:

.body-style {
background-color: #92CBE0;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#92CBE0',EndColorStr='#6B9EBC');
}

gradient filters on firefox

I am creating a website with a friend and we use the gradient code in the website. It works well however when we get our new computer system up and running we will be using FireFox instead of IE and the gradient code doesn't work in that, so is there a way we can do it with out making it upload an image every time?
sam bennett

Noelle Mallory - MSFT] Please post questions to the MSDN Forums at http://forums.microsoft.com/msdn. You will likely get a quicker response through the forum than through the Community Content.