background-image is not properly rendering only in IE9 - html

I am using the filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FFFFFF', endColorstr='#0000FF',GradientType=0 ); code to set the gradient background image in IE9.
Here is my fiddle.
The result in IE9 looks like,
But, i got trouble with the border-radius style.
What's wrong in my code? Is there any solution for this?
I have found the similar question on
IE9 round corners and filter: progid:DXImageTransform.Microsoft.gradient With answer of
Add the browser specific class or Set svg data as background image.
I don't like to use different css file or adding different HTMLElement based on browser version.
It might affect the performance of page when i use svg data as background-image.

You can add another element inside your .gradient_style which will have background-image and filter set. Then set overflow: hidden on parent element and you should be good.
Example CSS:
.gradient_style {
background: transparent;
height: 50px;
width: 150px;
border-radius: 25px;
border: 1px solid #050DFA;
overflow: hidden;
}
.gradient_style div {
background-image: linear-gradient(to bottom, #FFFFFF 0%, #00A3EF 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#00A3EF', GradientType=0);
width: 100%;
height: 100%;
}
And HTML:
<div class="gradient_style"><div></div></div>
Working sample: http://jsfiddle.net/DymK5/2/

This is a known bug in IE9, where a background gradient using the filter style ignores the border-radius and always renders the gradient into the corners of the element.
It is unfortunate that IE9 didn't implement standard CSS gradient syntax, which makes this kind of thing necessary.
There are work-around options, but they're all a bit ugly.
The most well-known work-around option is to use an SVG data-URL for the gradient, for IE9 only. The issues with this are that you still need the filter for IE8 support, and of course IE10/11 does use standard CSS gradients, so you need to start using conditional stylesheets to set the styles depending on the brower version. It gets ugly very quickly.
I wouldn't worry too much about performance of this; it should be fine. The problems are more with managing the code than with perf. (and in any case, even if there is a perf issue, it will only affect the specific browser version involved, IE9, so it will be a relatively small portion of your audience)
Another option is to use the CSS3Pie polyfill script. This is a good option because it allows you to use standard CSS code for your gradients in all IE versions. Since you say you dislike using different CSS for different browser versions, this is a big plus point.
The downside is that it is Javascript-based, so could have performance implications. But that said, I've never seen it have any perf problems with it, as long as you're not over-doing it (ie using it for hundreds of elements on the same page).
If all else fails, I guess there's always the option of simply just not supporting gradients for old IE versions, and having a plain solid-colour background fallback.

Related

In Razor view - how to detect browser type and version to select type of linear-gradient

I am trying to create and launch a website(C# .Net MVC) for the very first time using razor views .
I have used linear-gradient heavily in the website and since launching I realize that there is no support for gradients in IE versions 9 and lower
I would like to select gradient styles depending on browsers type and version.
For example:
#if(browser is IE 9 and under){
style="background: #ffffff;
}
Else{
style="background:linear-gradient(to bottom, #ffffff 0%,#ffffff 100px,#b8dbff 100%);
}
How can I detect the browser type and version in Razor view?
What’s the easiest way to filter browser versions that aren’t compatible with liner-gradients?
Hats off to front-end developers , I had no idea these cross browser issues are such a problem.
I myself use to complain a lot when something doesn’t work in a browser
You can use the Razor engine to serve a different view based on the caller, but it sounds like your situation can be handled with HTML/CSS.
If IE9 is your only problem, you can use conditional comments and include extra styles/stylesheet.
<!--[if IE 9]>
<style>
#foo { background-color: #fff; }
</style>
<![endif]-->
But for your particular question, you should be able do something even more simple and just modify your stylesheet:
body{
/* all browsers */
background: red;
/* newer browsers overwrite the previous value; old browsers ignore */
background: linear-gradient( to left top, blue, red);
}
IE9 doesn't know what "linear-gradient" means, and so ignores it. This is defined behavior upon which you can rely.
Demo: http://fiddle.jshell.net/K67yd/2/show/
You should take a look on Modernizr, a javascript library for detecting browser supported features. I guess it will do the job.
You might find something here: http://modernizr.com/docs/#features-css
And a good video for understanding the concept: http://css-tricks.com/video-screencasts/126-using-modernizr/

CSS Gradient Background Stripes instead of Smooth gradient

I am trying to achieve the following CSS background effect as in the following page.
However, instead of getting that smooth gradient, I get something like the image shown below.
My CSS:
body{
background:-webkit-radial-gradient(#205983, #0A2742); background:radial-gradient(#205983, #0A2742); overflow:hidden;
}
I want to achieve the same result. I Have no other CSS for the body.
From Chrome inspector (for the body element)
background: -webkit-radial-gradient(#205983, #0A2742);
background: radial-gradient(#205983, #0A2742);
overflow: hidden;
I've checked both pages on the same browser and I don't use any CSS reset code. How can I achieve the same results. Thanks.
The example page you provided works fine here in Google Chrome (v. 28.0.1500.95 m).
I've inspected the site's source. The css they use is:
#wrap {
min-width: 600px;
height: 100%;
position: relative;
background: -webkit-radial-gradient(#205983, #0A2742);
background: radial-gradient(#205983, #0A2742);
overflow: hidden;
}
Did you try using all the same css rules on your site? Mainly notice the height: 100%; rule. That might do something good.
Furthermore, the GPU and its settings on your machine might cause this problem to appear. But most of the time the problem originates from the rendering engine the browser uses. Sudden color-combinations don't harmonize, causing the shown effect.
Try slightly different colors. Use the colorpicker in Google Chromes Inspector (the small rectangle next to the color value of the css rule).
A recommendable online tool to generate CSS Gradients is: ColorZilla. It provides you with css (or sass css if desired) containing all common -vendor- prefixes and even adds IE support. I have positive experiences with it. Give it a try.
Good luck!

Text-Shadow in IE

I found a Stackoverflow article on creating text shadows in IE: StackQuestion
Now I tried all of the 'filter' solutions in there, and in IE9, the text renders horrible(although the shadow shadow shows, the text pixelates heavily...).
Does anyone know of a proper text-shadow technique for IE? Even if it is just for IE9...
Thank You
Check this site out: http://css3pie.com/
It's a plugin that enables you to use CSS3 in IE6-9
You can get text-shadow effects in Internet Explorer, taming IE's crunky filter shadow effects, forcing them to look okay and stop pixelating the text. Use the IE Chroma filter:
Set a background colour that is close to, but not the same as, your shadow colour - e.g. for black shadows, a dark grey, for white glows, a light grey
(set the background colour in a stylesheet or style rule inside an IE-only class or conditional comment, to not wreck your design in every other browser!)
Precede your IE filter CSS rule with a Chroma filter set to the same colour as the background fill
It looks (almost) quite good!
jsfiddle examples (load in IE8, IE9)
...or if you don't have easy access to IE8/9, here's a screenshot from that fiddle in IE9 IE8 mode. Notice the difference between the horrible, artifact-ridden, pixelated mess that is IE's default filter, against the quite crisp, normal-looking Chroma filter equivalents.
CSS code examples. Note how you've got a Chroma filter then another filter, all on one line, in quotes against one -ms-filter - and how the Chroma colour matches the background colour precisely, and how the Chroma colour compliments (but doesn't match) the main effect colour:
.chroma-glow {
background-color: #dfdfdf;
-ms-filter: "progid:DXImageTransform.Microsoft.Chroma(Color=#dfdfdf)progid:DXImageTransform.Microsoft.Glow(color=ffffff,strength=4)";
}
.chroma-shadow {
background-color: #dfdfdf;
-ms-filter: "progid:DXImageTransform.Microsoft.Chroma(Color=#dfdfdf)progid:DXImageTransform.Microsoft.Shadow(direction=135,strength=2,color=ffffff)";
}
Some requirements (learned the hard way...)
Elements must be block or inline-block, can't be inline.
Filters fail to apply to any children that are position: relative; or position: absolute;
(they work if applied directly to position: absolute; or `position: relative; elements)
If you're adding the filters dynamically, e.g. with jQuery like $elem.css('filter','progid...');, it seems like the background colour must be applied directly to the element with the filter for the chroma to work. A couple of tips:
Have the effect colour, applied background colour, and chroma colour all identical
Since you'll want this background colour only in IE, use feature detection or IE detection.
#element {
filter: glow(color=black,strength=5);
}

ie6 Showing Image(.PNG) background-color for a transparent background

Hi guys I have a problem of images showing background-color on IE6 and its supposed to be a transparent background. on all the other browsers it is showing fine except for IE6.
can anyone please tell me what am i doing wrong. tried the opacity to 0 but its still showing the background-color.
The fix is quite simple. No need to include any JavaScript. Define your css like this and include your image name in filter.
.whatever {
background: none; /* Hide the current background image so you can replace it with the filter*/
width: 500px; /* Must specify width */
height: 176px; /* Must specify height */
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='vehicles.png');
}
IE6 doesn't support semi-transparent PNGs. Try something like this for a work-around if you really need to:
http://css-tricks.com/snippets/css/png-hack-for-ie-6/
or http://www.jay-han.com/2008/10/15/unit-png-fix-best-ie-png-hack/
Or just drop IE6, it's way behind all other browsers, and fast losing market.
IE6 doesn't support transparent PNGs properly.
This page has a fix which involves a behaviour file. Alternatively you could use GIFs.

IE6 input box doesn't work, how to fix?

Little background information here: I have narrowed down the problem, but can't determine what the fix is. In IE6 the input box won't allow me to use my mouse to select it.
Please go here to see the problem: http://www.malahatautoparts.com/business-application/
The problems stems from an IE6 fix for the CSS background.
#main{
background-position:-9999px -9999px;
filter: progid:dximagetransform.microsoft.alphaimageloader( src='http://www.malahatautoparts.com/wp-content/themes/malahat/images/bg-main.png', sizingmethod='crop');
}
If I remove that from my IE6 css file, input box all of a sudden works.
Any ideas on what I can use to fix this?
The conditional comment you have there for "less than IE 7" isn't even working right for the PNG transparency it's supposed to fix in IE6: I'm seeing grey background around the transparent corner areas. In IE7 the transparency works natively without loading that stylesheet.
The method you're using in the IE stylesheet relies on the alphaImageLoader filter, which I suspect is blocking over top of the HTML form controls on the page.
There's an alternate method that uses VML instead: check out DD_BelatedPNG. I'm not 100% sure if it will solve your problem, but I have a hunch it will, and it's a cleaner solution than what you're using now.
<textarea> and <input> selections: selectionStart and selectionEnd are not implemented in IE, and there's a proprietary "ranges" system in its place, see also Caret position in textarea, in characters from the start.
Also see What are the typical reasons Javascript developed on Firefox fails on IE for common reasons of failure of Javascript/CSS in IE which work in Firefox & other browsers (or vice versa).
Some excellent tips so you can get a uniform look & usage in all browsers.
use css with
#main{
background-position:-9999px -9999px;
filter: progid:dximagetransform.microsoft.alphaimageloader( src='http://www.malahatautoparts.com/wp-content/themes/malahat/images/bg-main.png', sizingmethod='crop');
position: relative;
}