Posterous theme by Cory Watilo

Filed under: CSS3

CSS3 REVISITED — FEATURES & BUGS

Now that Opera has joined other browsers with their imple­ment­a­tion of CSS3 fea­tures, it becomes increas­ingly inter­est­ing to test and try these to see if they could become part of a stand­ard work flow.

This post focuses on just a few issues I ran into while exper­i­ment­ing. Perhaps later — or in another life — I might add some pos­it­ive example of the pos­sib­il­it­ies of these addi­tions but then again there are already plenty of people doing good work in that area.

Features

I had a look at the fol­low­ing features:

  1. Multiple back­ground images.
  2. Column lay­out module
  3. Text-shadow & Box-shadow
  4. Transitions & Transforms
1. Multiple back­ground images

In a test I did I noticed that Firefox did not yet sup­port this but worse: it does not degrade nicely. In my opin­ion it should just have used the first image lis­ted but instead I stared at a white back­ground with no image at all.

I have read that to have it degrade nicely you need to add an extra back­ground rule before you list the mul­tiple back­grounds. This seems rather bloated and unne­ces­sary to me.

Having said that, this would how­ever work as a work-around.

Example code
element {
    background: url(fall-back-bg.gif) top left no-repeat;
}
element {
    background: url(bg-one.gif) top left no-repeat,
                url(bg-two.gif) top 35px no-repeat,
                url(bg-three.gif) bottom left no-repeat,
                url(bg-four.gif) left repeat-y;
}
2. Column lay­out module

So far the column lay­out mod­ule has been imple­men­ted — to a degree — in Safari and Firefox. Opera (10.5) does not yet sup­port it. Google Chrome (Mac) is a web­kit browser but I’ve found a few dif­fer­ences between it and Safari.

I do think it is usable as it degrades nicely in browsers that do not sup­port it.

As we will see in examples below for now I think this should be used spar­ingly because for one Safari has a weak imple­ment­a­tion and also because I think most users will not like read­ing long texts on screen divided in columns that will make them have to scroll back up to read the text in the next column.

Used in sep­ar­ate blocks of con­tent with mostly just para­graphs could be a nice break in the flow of an art­icle and I think that would be a rather fair way to make use of this.

Issues with the column mod­ule layout

As said before by oth­ers the use of columns that have its text auto-flow through to the next column, does raise a few issues. Some have poin­ted out that cur­rently it is not pos­sible to keep cer­tain ele­ments together like hav­ing a head­ing attached to its paragraph.

On top of that I also do not see a way to keep a head­ing from flow­ing over mul­tiple columns should it be long enough and start­ing at the end of a column.

I know there are prop­er­ties called ‘break-before’ and ‘break-after’ and such but from what I under­stand from the W3C Candidate Recommendation of CSS Multi-column Layout Module is that these are only meant for prin­ted media. Please feel free to cor­rect me if I am wrong here.

Safari has some strange issues with these columns and I think these are bugs or rather a very poor imple­ment­a­tion of the mod­ule. Below you’ll find some examples of these issues.

While writ­ing this art­icle I noticed another glitch in Safari and how dif­fer­ent it acts as opposed to Firefox in regards to the multi column lay­out mod­ule. When I inser­ted the code above for the multi-background work around example, I noticed that in Safari the text is clipped on the right side, while in Firefox it is not and will act more like when overflow:visible had been set on it. I am not sure which one of these is at fault here. One could argue that because the code is inside a pre ele­ment the code should be shown ‘as is’ but does that mean the part that goes out­side the defined column should be vis­ible? Or not?

By the way: I fixed this for this post by redu­cing the font-size and adjust­ing the spaces before the text within the pre element.

Examples

Below are a few examples of the issues men­tioned with the column lay­out mod­ule. Click an image to see a lar­ger version.

A long header gets ripped apart.

Media_httpwwwnilshend_egjcq

All browsers do this the same way.

Images in strange spots.

Media_httpwwwnilshend_hmfni

Safari puts the image in a strange spot after set­ting a rota­tion on it.

Media_httpwwwnilshend_rbtia

Chrome for Mac does it even worse. The image goes out­side its column box.

Weird things going on with list items

Media_httpwwwnilshend_bshej

Webkit: list items with pad­ding flow over to the next column

3. Text-shadow & Box-shadow

Text-shadow seems to work in most browsers and should degrade nicely. Heck, offi­cially it’s a CSS2 fea­ture. Box-shadow now works in Opera (10.5) as well.

I did notice a glitch though when a drop shadow is set on an image that has a trans­ition applied to it. After the trans­ition has fin­ished — in my case it was a rota­tion from 5 degrees back to 0 degrees — some­times the shad­ows remain in their pos­i­tion for a frac­tion of a second before being redrawn.

Box-shadow on image ele­ments with a trans­form also have some issues. In all browsers when you have a trans­form set on an ele­ment like rota­tion of 5 degrees, it looks like the shadow is not being redrawn accurately.

4. Transitions & Transforms

As men­tioned above there are still issues with the trans­ition and trans­form fea­tures espe­cially in com­bin­a­tion with drop shad­ows or inside an ele­ment that has column-count set.

Border issues after rotation

Opera and Firefox both have issues draw­ing a bor­der around an ele­ment that has a trans­form applied to it. In this case a 5 degree rota­tion. In Opera the bor­der is just screwed up com­pletely, in Firefox as well but to a lesser degree.

A work around for this would be to not have the bor­der on the image ele­ment but a sur­round­ing ele­ment instead. But then we might as well stick to adding extra ele­ments for IE as well to cre­ate drop shad­ows and roun­ded corners, right?

Border issues with rotated images

Media_httpwwwnilshend_xicqf

Opera: Border around rotated image looks funny.

So now what?

Well I guess it depends on what you’re after with either of these fea­tures. Most of them are safe to use to a cer­tain extent as long as you know if and how it degrades in older browsers.

Some of these addi­tions to CSS could be real time savers and that will prob­ably be a reason for a lot of people to start using it. We will prob­ably see an even more accel­er­ated imple­ment­a­tion of CSS3 stuff in 2010 by all browser makers. I guess whether this is a good thing or not is for us — design­ers and developers to find out by keep­ing an eye on their implementations.

Proof of concept: Issues & Fun with CSS3 border-radius

A while back I wanted to have thumbnail images look a bit like the 'event-boxes' in iPhoto: square with rounded corners. Even though in the end I ended up having the rounded corners in the images themselves, I did do a test with the CSS3 border-radius property and here are some of the results.

Below you'll see the results as images, screenshots of the actual page. The test page itself is here.

Oh, the bearded guy in the used images is not Santa Claus, it's James Clerk Maxwell.

Supported browsers: Safari 3+, Firefox 3.1+

Examples

example 1

An empty div with rounded corners.

Media_httpwwwnilshend_sqdhr

Result: looks reasonable in Safari and Firefox.

example 2

Rounded corners directly on an <img> element.

Media_httpwwwnilshend_ciibd

Media_httpwwwnilshend_tbbap

example 3

Rounded corners on a div element surrounding the img element.

Media_httpwwwnilshend_jyswx

example 4

Rounded corners on a div surrounding the img element and a seperate rounded border on the image itself with a slighty different radius.

Media_httpwwwnilshend_hhbfa

Result: Safari does this in an acceptable way. Firefox does not, it is the same as the ones before.

The spec

The fact that the borders go behind the image is actually according to the W3C working draft for CSS3.

“Borders are drawn in front of the element's background, but behind the element's content (in case it overlaps).”

Source: http://www.w3.org/TR/css3-background/#borders

So far only Safari delivers something useful. The only work-around I have found so far that could work cross-browser is to set the image as a background image on the element. But that is hardly a usable way when your site has lots of inline images whether they are CMS generated or not.

Related reads

Here's another article that describes the same issue. The author also took the trouble to file this as a bug issue. I do think though that the version where the rounded corners are set on the surrounding div, is right, that is, according to the spec and should probably not be fixed. Only in the case that the rounded corners are set on the image itself should the border either go over the image or clip its sharp corners.

Taking it further: breaking out

Here's an example of what you can do with the fact that the borders are being drawn behind the element's content. In this case you can have the arm of the athlete break out of its box through the borders. (if it's a transparent PNG)

Note that the blurryness is only in the screenshot. Who knows why?

Media_httpwwwnilshend_fgeup