Consistent CSS3

Hi guys,

I have been trying my best to keep up with all the latest web tech like HTML5, canvas, CSS 3 etc. and in doing so, I feel that I have taken in what I needed to in order to find out how it all works. Now I am in need of some clarification, especially with regard to CSS 3 to make sure that I am consistently cross-browser compatible.

So a few little things:

  1. Border radius

At the moment I do:

-moz-border-radius: 35px;
border-radius: 35px;
-webkit-border-radius:35px;

Is this ok or is there some other cross-browser code to add?

Also I am confused about which rules to do with regard to gradient. Here is my code for that, created by a gradient generator online, is this cross-browser compatible? Are there any rules missing? Could some also tell me what on earth the “filter” syntax is all about?

background: #1e5799; /* Old browsers /
background: -moz-linear-gradient(top, #1e5799 0%, #2989d8 0%, #1b49ad 0%, #1697dd 56%); /
FF3.6+ /
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(0%,#2989d8), color-stop(0%,#1b49ad), color-stop(56%,#1697dd)); /
Chrome,Safari4+ /
background: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 0%,#1b49ad 0%,#1697dd 56%); /
Chrome10+,Safari5.1+ /
background: -o-linear-gradient(top, #1e5799 0%,#2989d8 0%,#1b49ad 0%,#1697dd 56%); /
Opera 11.10+ /
background: -ms-linear-gradient(top, #1e5799 0%,#2989d8 0%,#1b49ad 0%,#1697dd 56%); /
IE10+ /
background: linear-gradient(top, #1e5799 0%,#2989d8 0%,#1b49ad 0%,#1697dd 56%); /
W3C /
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=‘#1e5799’, endColorstr=‘#1697dd’,GradientType=0 ); /
IE6-9 */

Thanks very much

Hi,

The order is important with these vendor prefixes, you need to put the prefixless version last.


-moz-border-radius: 35px;
-webkit-border-radius:35px;
border-radius: 35px;

You might prefer to use a solution like http://leaverou.github.com/prefixfree/ which will add the prefixes client-side, or make mixins with SASS to compile these before you deploy.

I don’t think consistency should be the aim for these css3 features.
As a rule I don’t use IE filters ever because of performance issues and it’s fine if gradients, rounded corners and shadows aren’t present if your browser doesn’t support them natively. I also don’t apply different syntaxes so don’t use the older -webkit-gradient syntax.

I would prefer something like this:


background: #1e5799; /* always provide a background-color */
background-image: -moz-linear-gradient(top, #1e5799 0%, #2989d8 0%, #1b49ad 0%, #1697dd 56%);
background-image: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 0%,#1b49ad 0%,#1697dd 56%);
background-image: -o-linear-gradient(top, #1e5799 0%,#2989d8 0%,#1b49ad 0%,#1697dd 56%);
background-image: linear-gradient(top, #1e5799 0%,#2989d8 0%,#1b49ad 0%,#1697dd 56%);

Hi Mark,

Thanks so much for your replay. I wasn’t aware of the order importance and the prefixfree software looks great. Do you use that your self? How reliable is it?

Also I don’t know what filters are really, all i know is that I have gradients working when I test on IE7 which I was surprised to see. But you advise not to use grad/drop shadow generators, which browsers will I have to allow to gracefully degrade if I do this?