views:

219

answers:

2

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.

A: 

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".

Syntactic
Thanks Syntactic for your quick answer, i'm sorry but i'm not a native english speaker, RegDwight did changed my message
Wiika
+1  A: 

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. :)

Radu
Yes your'e right, i have a public website and not all my users use modern browsers , most of them still use internet 6-7, there is another way to gradients for all elements in page is by using just one transparent image ( gradient: white to transparent i believe ) but i'm not sure how to make it in photoshop
Wiika