Resource icon

CSS3 Gradient Correct Application

If you put them into the extra css box in style properties, you will absolutely corrupt the background, as the style properties only allows one background, it confuses additional properties.

You are best to hard code gradients into the stylesheet directly, outside of the @property.


It's actually really simple, because you only create the default gradients you use already, then you copy and paste them into each class that requires them, adding only the style colour property to the beginning that enables colour changes to then be made via the colour style properties.

It takes a couple of hours to do initially, then its all easy sailing from that point forward with further style changes.
Woah @ a couple hours. If it's going to take that long, I would only want to do this for my own site's skin and create one new skin to release in the resource manager that uses this. If you or someone showed me how to do this I'll even put your site's link in the footer of the style I release cause I'm still not understanding what you all mean.
 
Woah @ a couple hours. If it's going to take that long, I would only want to do this for my own site's skin and create one new skin to release in the resource manager that uses this. If you or someone showed me how to do this I'll even put your site's link in the footer of the style I release cause I'm still not understanding what you all mean.

You're missing the point and advice your being given. I'd say I can do what Anthony is kinda suggesting in say 20 minutes? so let's take this further... let's say after doing the initial style which took you around say an hour for arguments sake and you wanted to create other colour variations of the initial style, derivatives so to speak you could literally make a full style colour change in minutes. Does that sound more appealing?

I think your looking at this as a big job, a task that is complicated and time consuming. It's not, in the long term it'll save you hours of work. But bare in mind, css gradients can be limiting and there are restrictions what you can do but if your after simplistic linear type gradients then you'll enjoy seeing the benefits.

Personally, i love nothing more than overloading pages with my more complex gradients/patterns :p but that's my preference.
 
Woah @ a couple hours. If it's going to take that long, I would only want to do this for my own site's skin and create one new skin to release in the resource manager that uses this. If you or someone showed me how to do this I'll even put your site's link in the footer of the style I release cause I'm still not understanding what you all mean.
What Shelley said.

In relation to the flexile style, as an example, I did the top level light, blue, skin. There are then various other colour combinations that are children of that skin. The time wasn't in CSS3, that took less than 15 minutes total. The time was in finding each and every existing gradient in existing style sheets, then adding the relevant one to them, adding the style colour property to each.... hence a top level skin then allows all children as well to now benefit from CSS3.

As Shelley stated... it has uses and limitations. It has server benefits for heavily used sites, when you start looking at all the little things to minimise server load to improve performance to your user base.
 
So this absolutely has to be done in the individual .css template files...

What about creating an extra css file with that edit and using 'include template' then sticking it in a template through TMS?

I just want my styles to be easy for people to upgrade without having to revert templates, that's all.
 
You can use the TMS... I had some issues with a couple of CSS imports corrupting doing it, though for the most part it did work.

You can add them really where you want. To be honest, all placed on their own template and fed into say the public css template, as an example, is probably better than using TMS, as CSS3 RGBa can be funny if not loaded directly.
 
You can use the TMS... I had some issues with a couple of CSS imports corrupting doing it, though for the most part it did work.

You can add them really where you want. To be honest, all placed on their own template and fed into say the public css template, as an example, is probably better than using TMS, as CSS3 RGBa can be funny if not loaded directly.
I had problems with the TMS system and I suspect others will too so what I'll do is just edit the css templates directly. Reason I decided to go through with this is I was studying the Macbook Pro with Retina and your CSS3 resource would be the best way to make site's retina-ready.
 
Nice guide. All of my future styles will be using CSS3 gradients before any image fallbacks, for some of the reasons you listed here.

However, there are still a number of problems with CSS3 gradients that have prevented me from eagerly jumping on top of them.

First of all is the fact that most browsers do not dither CSS3 gradients. This doesn't seem like such a huge problem at first, but can actually be a deal breaker in many cases. Many designs will use a very subtle CSS3 gradient to add a slight sensation of depth or shine. The problem is that because the two color stops are not very far apart, and the gradient is not dithered, color banding is quite easily visible in the gradient area, which is unacceptable. You end up more with a series of stripes rather than a cleanly graduated area. I'll use an image over CSS any day if banding is going to be an issue.

The second issue is browser performance. "What?" you say. "CSS gradients will improve performance." Yes, that's true when you're talking about loading performance. The other area of website performance which I consider just as important, if not more so, is the rendering performance of the browser on any given page. The simple truth is that complex CSS effects like gradients, drop shadows, rounded corners, transitions, filters, etc. put a lot of computation duty on the browser which was previously handled by an image editor when the image was exported. Combine this with the fact that most browers are not GPU-accelerated, and lots of complex CSS can slow on-page performance to a crawl.

Perhaps it's because I am a video gamer and I am very sensitive to changes in FPS (frames per second), but when complex or poorly-coded CSS brings a web page from rendering at 60 fps (a buttery smooth experience, technically as smooth as the image can be rendered on most modern monitors) down to 20 fps or lower, it's annoying and can make the site feel "slower" than a site that renders much faster but took twice as long for the initial load. Considering that most of a user's time on a site is spent interacting with the loaded page rather than waiting for it to load, I'm surprised that more attention hasn't been paid by browser makers to the rendering performance of their browser. Is it really worth it to shave 1oo-2oo ms off the load time of your page if it means that your site feels very "laggy" when the user is actually using it?

The third "issue", in my mind, is that CSS gradients as they stand today don't bring any design advantage compared to the transparent PNG approach that I used with Flexile. Both approaches allow the style to be easily customized by simply changing the base color, as the transparent overlay maintains the graduated appearance. However, they both have the same drawbacks, mainly that you can only overlay white, black, or some shade of gray in between. As a result, this inherently washes out the color in the gradient. The ideal method would be a way to overlay an increase in luminance, allowing you to create a gradient overlay that increases brightness without decreasing color saturation. In other words, we need blend modes for the web. Adobe has advocated for doing exactly that, but it's still a long way off. However, in 10 years from now, I'm willing to bet that images will be entirely out for the UI design of sites. With @font-face, CSS gradients, rounded-corners, drop-shadows, SVG icons, and eventually filters and blending modes, as well as the improvement of browser rendering performance (which I anticipate will be the next performance war, after Javascript), images will be relegated to what they were originally intended for: displaying photographic content.

Intelligent CSS extensions like SASS and LESS, combined with CSS3 gradients, could provide a stop-gap solution for the time being. SASS has color functions like hsl(), lighten(), and saturate(), so it would be theoretically possible to do something like linear-gradient(top, @myColor, lighten(@myColor, 20%));. It's been goal of mine to implement a SASS parser that slots into XF's template compilation process, but I have neither the time nor the skills. If it did eventually get supported, the fact that XF already compiles the templates means that themeing possibilities would get blown wide open.

So there's my 2¢ on CSS3 gradients. :)
 
Alright I took the time to work on this when I was bored at work and I finally figured out how to use it. I'm so happy!!! This is awesome beyond belief!

Here's a sample of a theme using nothing but CSS3 gradients that I'm working on to post in the resource manager. I basiclally just took the SMF Silver theme I made and am replacing the gradients and changing the colors etc. Not done yet.

sample.webp
 
Looks like my site is loading 2 seconds faster and I haven't even finished replacing some of the gradients!
 
Yep... CSS3 gradient replacement is a single noticeable performance improvement by itself. Well done on your own learning. It isn't as hard as some think it is... as even better if you stay away from coloured gradients, and instead stick with a background colour and then make the gradient white / grey / black, and apply opacity, thus giving a finish that still caters quick and easy colour changes.

Nice work.
 
Yep... CSS3 gradient replacement is a single noticeable performance improvement by itself. Well done on your own learning. It isn't as hard as some think it is... as even better if you stay away from coloured gradients, and instead stick with a background colour and then make the gradient white / grey / black, and apply opacity, thus giving a finish that still caters quick and easy colour changes.

Nice work.
I don't know how to do that part yet. When I tried to make it opaque and keep the background color it didn't work. So I've just been using solid gradients. :(
 
One of the better ways is to simply include, background: #color; as the last entry, below the gradients. For example, to make a grey background with shiny white gradient over it, use:

Code:
background: -moz-linear-gradient(top,  rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#00ffffff',GradientType=0 ); /* IE6-9 */
background-color: #ccc;
Or, you can include the background color first in each gradient, such as:

background: #ccc -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%); /* FF3.6+ */

That works for normal circumstances, though XF style system can have issues with it in templates... so I've found simply including the background colour as the last entry is the better solution. This ensures a base colour is applied, and the browser will apply the gradient as well, without being color specific.
 
If you're making styles available, then the above is the best way, as you make a CSS gradient once, then use it in all styles... you just change the background-color only, which normally you simply use a color style property @property;
 
If you're making styles available, then the above is the best way, as you make a CSS gradient once, then use it in all styles... you just change the background-color only, which normally you simply use a color style property @property;
So since the background color in styles properly is rendered useless, I take THAT background color and put it at the bottom of the CSS3 code I put?
 
Unrelated but I noticed that when I closed the tab and opened up the ultimate css gradient page in another tab my previous edits were saved. If I close the whole browser will it still save my edits? How is it doing that? WTF?
 
Local issue that has nothing to do with CSS.

So since the background color in styles properly is rendered useless, I take THAT background color and put it at the bottom of the CSS3 code I put?
Pretty much, yep. Put that after the CSS gradient as the background color, and all is well allowing full colour control from style properties then.
 
There are always changes, however; they are also backwards compatible much better than forwards compatible, for older browser versions. There are lots of ways to actually write css gradients. There isn't just one. Subtleties exist.
 
Top Bottom