Log in

View Full Version : How to target IE only



cryoffalcon
05-08-2012, 07:46 PM
Hi,
I want to use this gradient background only for IE


background: #4f4f4f;
background: -moz-radial-gradient(center, ellipse cover, #4f4f4f 0%, #0e0e0e 100%);
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#4f4f4f), color-stop(100%,#0e0e0e));
background: -webkit-radial-gradient(center, ellipse cover, #4f4f4f 0%,#0e0e0e 100%);
background: -o-radial-gradient(center, ellipse cover, #4f4f4f 0%,#0e0e0e 100%);
background: -ms-radial-gradient(center, ellipse cover, #4f4f4f 0%,#0e0e0e 100%);
background: radial-gradient(center, ellipse cover, #4f4f4f 0%,#0e0e0e 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4f4f4f', endColorstr='#0e0e0e',GradientType=1 );

there are methods that are for style sheet I don't want to use them as I want IE to use all the css that is for all browsers only that IE don't read the part of the gradient I want it to use the gradient above instead.
How can this be done?

djr33
05-08-2012, 07:59 PM
Use "Internet Explorer conditional comments" (search Google for more info).
You might need to put the whole <style> tag in the comment.

Alternatively, you might not need to do anything-- it looks like you're using IE-only "filter", some "webkit" properties, and some "moz" properties. Also "ms" (microsoft?). So that should apply on those specific browsers.

cryoffalcon
05-08-2012, 08:10 PM
Use "Internet Explorer conditional comments" (search Google for more info).
You might need to put the whole <style> tag in the comment.

Alternatively, you might not need to do anything-- it looks like you're using IE-only "filter", some "webkit" properties, and some "moz" properties. Also "ms" (microsoft?). So that should apply on those specific browsers.

I first searched google before coming here :P It was only showing how to completely write a new style sheet for IE while I only want a background to be changed.
And no this is not for IE or other, I am using radial gradient at the moment which in IE looks like a horizontal gradient which would have been okay but there is a problem that It creates the white part of gradient stays on left while I want it on right, that's why instead of IE using the radial gradient I want it to use the one that I have added above it is a horizontal one with white side on right as I want ^^

djr33
05-08-2012, 09:22 PM
I don't know of a way other than using a special IE stylesheet. That's pretty common.

traq
05-09-2012, 07:46 PM
IE ignores most of the rules you posted.
/* this works in NO current browsers (IE10 will support it) */
background: -ms-radial-gradient(center, ellipse cover, #4f4f4f 0%,#0e0e0e 100%);
/* this works in CURRENT versions of IE. */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4f4f4f', endColorstr='#0e0e0e',GradientType=1 );Just put these two rules after all the other rules in your regular stylesheet.

IE will use them; all other browsers will ignore them.