Utilize ASP.NET theme specific to browser and browser version - asp.net

My team is developing an ASP.NET web application, and we are attempting to maintain a consistent look and feel across browser type and version for a couple of the major browsers(IE, Chrome, Firefox). We would also like to allow themeing if possible , so that users can have a choice of color, font size, and so on.
However, I am having a serious issue with Acheiving compatibility with IE 8 and 9 due to some CSS3 rules currently in place. In particular, the shading gradient's used in this div are causing trouble, as they are not supported in IE 8 or 9:
#logos
{
width:1024px;
height:100px;
border-radius:15px;
color: -moz-linear-gradient(bottom, #297381, #FFFFFF);
color: -ms-linear-gradient(bottom, #297381, #FFFFFF);
color: -webkit-linear-gradient(bottom, #297381,#FFFFFF);
background:-moz-linear-gradient(bottom, #297381,#FFFFFF);
background:-ms-linear-gradient(bottom, #297381,#FFFFFF);
background:-webkit-linear-gradient(bottom, #297381,#FFFFFF);
}
I believe(correct me if I am wrong) I can achieve the gradient in IE9 by adding these rules:
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#297381', EndColorStr='#FFFFFF')";
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=’#297381’, EndColorStr='#FFFFFF');
But I don't think there is any corresponding option in IE8 and I don't believe it supports border-radius either. I was hoping to just have a separate theme or rule utilizing a static image for the background of that div. Is there any way I can detect browser version in css and apply the correct rule or theme? Or does this have to be done in the code behind and set the theme accordingly from there?

Try CSS PIE - http://css3pie.com/. This is a library which enables CSS3 functionality in IE6-8 via behaviors in a .htc file.

Related

CSS background-color not working in chrome

I got this background-color here
-moz-linear-gradient(center top , #0043A1 0%, #0043A1 100%) repeat scroll 0 0 transparent;
but it will not work in google chrome, any ideas on how to fix it?
Thanks,
J
Replace with
linear-gradient(center top , #0043A1 0%, #0043A1 100%) repeat scroll 0 0 transparent;
-moz-* css properties are specific to mozilla. They're useful while a property isn't normalized but now (with CSS3) you may use the standardized linear-gradient.
Even the Mozilla documentation now documents linear-gradient.
Use this for Chrome and Safari browsers:
-webkit-linear-gradient
And use this for Mozilla (Firefox):
-moz-linear-gradient
You might like the site CSS3Please! which lets you see how to apply all these various properties, and generates the code for all browsers (even Opera, which most people often forget but which they really really shouldn't. So sayeth a diehard Opera user.) There's also ColorZilla's Gradient Generator, which I've found to be a little less intuitive...but it does generate the CSS styledefs as well.

CSS linear gradients not working on live server (IE only), fine on localhost

I have just rolled out a new Intranet that ive been working on for some time.
All is good (apart from the inevitable user-centric issues and a couple of bugs)
However its just become apparent (now that i have a chance to actually look at the front end as opposed to hacking code to fix problems) that for some reason my css linear gradients arent working.
This is very odd to me, as when i view the same site in its test environment (localhost) the gradients work in all their glory. on the same PC, in the same browser (2 tabs open, one local, one external)
all other css (in the same style file) works fine.
#PageTitleBox{
position:absolute;
left:0px;
top:2px;
width:169px;
z-index:3;
padding-top:0px;
padding-bottom:10px;
padding-left:10px;
padding-right:10px;
background-color:#A9D4CC;
background-image: -webkit-linear-gradient(180deg, #A9D4CC, #7DB4B3);
background-image: -moz-linear-gradient(180deg, #A9D4CC, #7DB4B3);
background-image: -o-linear-gradient(180deg, #A9D4CC, #7DB4B3);
background-image: linear-gradient(180deg, #A9D4CC, #7DB4B3);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr='#7DB4B3', endColorstr='#A9D4CC')";
height: 55px;}
OK. I reckon you may have IE9 switched to compatibility view. (http://stackoverflow.com/questions/3726357/why-does-ie9-switch-to-compatibility-mode-on-my-website).
You can include <meta http-equiv="X-UA-Compatible" content="IE=Edge"/> in your HTML HEAD to instruct IE to not do this, or set the equivalent HTTP response header using the server.
IE might ignore this anyway if the reason is your live server is considered to be part of your Intranet Zone by IE. In which case you have to configure IE not to use Compatibility View for intranet sites, in the Compatibility View settings.
You can set 'Enabled' property of the gradient object to true.
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(enabled='true', GradientType=1, startColorstr='#7DB4B3', endColorstr='#A9D4CC')";

How can I display a CSS linear gradient in Netscape?

How do I use a CSS linear gradient with Netscape?
I am trying this code:
#gr {
background: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#000));
background: -moz-linear-gradient(top, #ffffff, #000);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#000');
-ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#000');
}
It works with IE, Firefox, and Chrome but it does not work with Netscape.
Netscape Navigator 9, last updated between 2006 and 2008 as a Firefox derivative, does not offer any real support for CSS beyond a large subset of the CSS2.1 spec. It does not support CSS3 gradients, or most any other CSS3 feature.
Netscape Navigator/Communicator 4.x and older don't have a lot of CSS support at all.
If you really need a gradient, you're better off using a background image. That's the traditional, tried and tested method designers have been using for the past 10 years, with great cross-browser compatibility yet very little friction.
If you're trying to support Netscape only because you are a Netscape user, stop wasting your time. Switch to Firefox. No serious web designer uses Netscape anymore in this day and age.
Netscape is no longer supported and is very rarely used by anyone.
But if you still want to use a linear gradient on your site, you can create an image using Photoshop or any other graphic editor, and then use it as:
background-image: url('url-of-img.jpg');

css property not working for IE6

I have this :
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(255,255,255,0.56)), color-stop(100%,rgba(210,210,210,1)));
Its working for all browsers and for IE9 , but not working for IE6
Can someone tell me what to use else
Regards
You need to use IE's old filter rules, the rule you mentioned in the question has a vendor prefix which is targeting webkit (chrome, safari etc) browsers only. - there's a neat generator here which will help you out in making cross-platform gradients. IE6-9's rules look like this:
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 *
The webkit prefix only works in Webkit browsers, which are Chrome, Safari, and Android and iPhone. For example, you'd need to use -moz for Firefox, and -o for Opera.
IE6 doesn't have any gradient support at all, so you'll need to use an image instead, or drop IE6 support, which is probably a good choice; not many users are still on IE6. (Unless this is meant for use specifically in for example governments, they're often stuck.)
Internet Explorer gradient filter doesn't support color-stop, gradient angle, and radial gradient. That means you can only specify either horizontal or vertical linear gradient with 2 colors: StartColorStr and EndColorStr.
Internet Explorer 8 and lower aren't the only browsers that don't support gradients, so using filters won't catch all browsers.
Another approach is to use Modernizr to feature detect support and use a fallback image or solid colour.
For example:
#box {
// Normal gradient syntax
}
.no-cssgradients #box {
// Fallback image
}

Using CSS gradient instead of images

Using CSS for creating gradients instead of images, does it have any negativity?
For example the following code:
#gradient {
color: #fff;
height: 100px;
padding: 10px;
/* For WebKit (Safari, Google Chrome etc) */
background: -webkit-gradient(linear, left top, left bottom, from(#00f), to(#fff));
/* For Mozilla/Gecko (Firefox etc) */
background: -moz-linear-gradient(top, #00f, #fff);
/* For Internet Explorer 5.5 - 7 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#FF0000FF, endColorstr=#FFFFFFFF);
/* For Internet Explorer 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#FF0000FF, endColorstr=#FFFFFFFF)";
}
Thanks.
Gradients are not standardized yet and many browsers do not suport it, in your exemple -moz-linear-gradient works in firefox 3.6 but on older version doesn't. If your site is for public purposes, many people won't see you gradients, so you could check what version of browser they use, and use gradients or images based on that. I use gradients on an intranet site (where I can force users to use a specific browser), If the browser if not Firefox 3.6 or greater, the site will show just a message that tells the user to upgrade, but this is not a good way if you go public.
So i choose negative for public sites. :)
As you've illustrated in your example, there's no one way to do it that works in all commonly used browsers at the moment. I would consider that a "negative" for maintenance and code readability purposes.
A bit of constructive criticism: the word you're looking for is "instead", not "instant".
CSS gradients are used on many large websites using the fallbacks you are using. I would add PIE.htc as well. If you do use PIE remember that it needs to be absolutely or relatively positioned to show up.
If you have to support really old browsers the best way is to give them a fallback solid background-color.
To be it it silly to expect old browsers to display gradients at all. If you absolutely have to you can set up a conditionally loaded stylesheet:
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="http://mysite/css/ie7_hacks.css" /><![endif]-->
In there you can declare a repeating image-based gradient. Just like how it used to be done before CSS3.
By doing it this way you are making your site a little faster for modern web browsers.

Resources