A bunch of my testcases.
@Jonathan: Thanks for the great overview in your post!
will all this work in IE ?
Hey, thanks for the examples, I was looking in Firefox stupidly and seen nothing but normal pictures (Jonathan) and blue backgrounds (Thomas) but I realised pretty soon that it is probably that my version of Firefox does not support this kind of CSS despite the vendor prefix -moz which seems to be ignored. (Firefox 3.5.7)
I took a look in Chrome and saw some interesting results (Jonathan) and some potentially useful results (Thomas). I had never heard of using multiple CSS backgrounds and things as I am too busy doing commercial work and don't work in the research and development department although I will be passing on the details.
On the other hand, I have wanted something that allows me to apply multiple backgrounds to a layer for some time as it can be tricky to write semantic XHTML while achieving everything the designer has came up with.
will all this work in IE ? and windows browsers? please let me know this.... waiting for ur response snook and ur effort is great
I'll step in and answer for Mr. Snook: no, this will not work in IE.
Gradients work in Safari 4 and Firefox 3.6.
Wow! I can't wait to see this working in all major browsers. Will be a great step forward!
We waste alot of time with ie6 hacks for some people who "don't feel the need of upgrade" they dont't know how much we work just so they can see our site's in ie 6
>> I'm also going to take a moment right now and rant about vendor prefixes.
@APE WEB: Elements with multiple background images are supported in Firefox 3.6, Safari 4.0.4 and in the latest version of Chrome. Firefox 3.5.x as well as IE don't support this feature - and in the case of IE we will at least have to wait for IE9.
But Jonathan, surely you'd want it mentioned somewhere that vendor prefixes are A Good Thing? :-)
I can vividly feel your pain during this transition period, but it's better than browsers attempting an implementation at one or the other CSS feature, fail at following the specs, and then you'd end up with a single rule that is interpreted differently across browsers. That's where all those underscore and funky comments hacks came from, no? Your background-size example somewhat proves my point: Chrome shouldn't have picked up the non-prefixed rule until they get it right (although I guess it doesn't hurt to explicitly specify both dimensions), and it's definitely good that the different approaches to gradients aren't using the fully fledged rule, as it could never work cross-browser as of now.
And with regards to you not wanting IE to be innovative: This is only down to their rare releases, right?
I mean, we're excited about all other browsers' innovations, want to use it in production while it's still smoking hot, and of course equally want browser vendors to compare notes of how they interpret the specs, and, once they support the real rule, all do the same thing across the board. If IE was releasing CSS rendering changes every few months or so, we'd love them to come up with experimental (prefixed!) implementations of every draft css rule we can think of, right?
Even if all this stuff is not widely supported (will it ever be ?) is good to learn/now/use it, so thank you for this post. Bookmarked
In most cases, people over do the nested divs. I go for a minimalistic and semantic approach when using divs and think others should follow this approach, and if the designer comes up with something snazzy then find a way of making the design work without bloating the page.
Although, saying that, this will not always be possible and therefore multiple CSS backgrounds will be very useful. Just because multiple CSS backgrounds will one day be supported, I think we should all stick to our roots and try and create semantic HTML first and worry about the CSS later.
It's the first time I've read something about these Multiple Backgrounds. Very interesting. Thank you!
I had a look at these features of CSS3 a while ago and would really like to use them on websites that I design but the only thing stopping me is IE as it doesn't support any CSS3 as of yet.
These are definitely good features and maybe I can use them on my personal site. Thanks for sharing this information.
Yep, one day this will all be very nice, hope that day comes soon...
a great read....really interesting!
I cant wait to use these new techniques soon. I just hope the dust settles with all the different requirements for different browsers...
thanks for sharing!
Have you tried simulating Photoshop's Gradient-Stroke with just css and without using a wrapping div?
I tried but haven't gotten very far:
Matthias Willerich has it right - vendor prefixes are a Good Thing, as long as they continue being used as they currently are, as a way to do early experimentation with new features.
If browser vendors didn't use prefixes, we'd be in *tons* of trouble when some particular browser's impl gets popular but then we want to change the spec. Frankly, we'd be unable to. It would freeze mistakes in time forever.
A vendor prefix at least means that you know what you're getting into when you use it on your page. It's early, it's experimental, it might change before being finalized and losing the prefix. In the meantime, you can play with it and see if it meets your needs, and potentially get the spec changed if it's not good enough.
The whole situation does get confusing when there *is* significant change between implementations, I'll admit. The differences in webkit and mozilla-prefixed gradients make them pretty weird to work with right now. But that's because webkit came out first with an experimental implementation, I thought it sucked and wrote a new syntax that made its way into the Images module, and mozilla implemented the new one in the spec. It still might change *slightly* before we take Images to CR (which is the point at which it is appropriate to drop the prefix), but all the simple uses of -moz-*-gradient() should continue to be correct until the standard is finished.
That all said, good post! I just added Moz-style gradients to my company's site template, so you can see them used in action at http://www.igofigure.com. It's astonishing how much you can speed up a page load by swapping images of gradients for CSS-specified ones.
I have been researching how these pieces can create clean text rendering. This article was informative. I'm hoping to leverage CSS3 gradients and a 1px stroke to create text effects usually only relegated to Photoshop and sIFR.
Thank you for your tips here, Jonathan! The WebKit team's descriptions of gradient just was not as easy to comprehend and understand as yours. I now believe I actually understand the parameters that I'm using thanks to this blog post. Much appreciated!
I'm really Glad i ran across this site.Added www.avmdanse.com to my bookmark!
Thanks for the excellent post.
background:url(acceldom.jpg) 10px 5px no-repeat ,
url(Examples.gif) right 5px no-repeat,-webkit-gradient(linear, 0 0, 0 100%, color-stop(0,rgba(0,0,0,0)), color-stop(1,rgba(0,0,0,1))) 0px 0px no-repeat;
background-size:180px 250px, 20px 20px 10px 10px;
i was expecting the last gradient, to be of 10X10 size. But the gradient was spearding the whole paragraph.
Your "background-size: cover" tip ended days of frustration. Thank you VERY much.
This is an absolutely fantastic walk through. You just saved me a tone of work and extra lines of z-indexing for floaded div's and all sorts of ****.
Great, GREAT demos as well.
Hello There. Thanks very much for your article, very useful information! I'm dealing with gradients and background-images at the moment. I was wondering if its possible to combine these two, and YES it is :) Thank you!
Hi. My name is Jonathan Snook and this is my site. I write about what interests me, which is usually web design, development, and technology. I'm also in the middle of a food adventure and I like whisky.
I wrote SMACSS. I tweet. Want to learn more?
© Jonathan Snook