-
200718 Sep
Posted in Browsers, CSS3 Previews, Tutorials
Until the Advanced Layout and Grid Layout modules are implemented, we have to get by with the existing tricks of the trade. One of those is the use of faux columns, a background image which simulates equal-height columns. This is a good technique, but the drawback is that it only works with fixed-width columns.
That problem was overcome with the advent of liquid faux columns, which uses some
background-positiontrickery and a bit of maths to create a variable-width effect.With the (tentative) introduction of
background-sizein Safari and Opera, however, faux columns are about to become a lot easier; all you need to do is create a background image and assign a percentage value to background-size, allowing the image to expand or contract with its containing box.Take a look at this example (only tested in Safari 3 and Opera 9.5; may work in Konqueror 3.5.7 also). If you resize your browser window, the text and columns should maintain their proportions.
The way this is done is with a simple PNG image; I’ve made it 1000px wide, with two coloured columns of 250px each, so that it’s easier to calculate column widths (25%,50%,25%).
I’ve set this as the background-image on the html element, which has been assigned a width of 90%. Inside this there is a container div with a width of 100%, and my three columns with the widths set at the same ratio as the background image:
<div id="container"> <div id="one"> </div> <div id="two"> </div> <div id="tre"> </div> </div> #container { position: relative; width: 100%; } #one { margin: 0 25%; } #two, #tre { position: absolute; top: 0; width: 25%; } #two { left: 0; } #tre { right: 0; }The html element has the
background-sizedeclaration applied to it, with a percentage value to make it liquid, using the browser-specific prefixes followed by the proposed declaration (for safety):html { background-image: url('opera_bg.png'); -khtml-background-size: 100%; -o-background-size: 100%; -webkit-background-size: 90%; background-size: 100%; background-position: 50% 0; background-repeat: repeat-y; width: 90%;You’ll notice that the Webkit value is different from the others; during this test, it seems that Webkit obtains its width from the entire browser window, not from the containing element; therefore, we have to set this value to be equal to the width of the containing element. I haven’t tested this thoroughly yet, so I’m not sure if this is a persistent bug or if there’s something I’m doing wrong. Anyway, Opera 9.5 behaves as expected.
After that I’ve added the
background-positionandbackground-repeatdeclarations;background-repeatto tile the image down the page, andbackground-positionbecause Webkit seems to ignore themarginvalues and puts the image at top left of the browser window; this is only necessary if you’re centre-aligning your page.Apart from a little tidying up, that’s it; once the module becomes a recommendation and the browser-specific prefixes are dropped, it will require only a few lines of code for the simple effect. In the meantime, remember that this is for experimentation purposes only and shouldn’t be used in a live environment. This is just a sketch of the technique at the moment, and requires more testing.
-
200705 Sep
Posted in CSS3 Previews, News
We’re busy here at css3.info! Our interview with H&kon was cool of course, but then Opera 9.5 was released and we had to update and add quite a few pages… Because all these pages were still static html, that was quite a bit of work. Tonight I took the time to move all of them into WordPress, and after I’d done that, I’ve refined the search function and results a bit, so it now shows the pages in the searches as well!
We’ll probably be adding new preview pages in the coming days, I’ve already updated the existing ones which Opera 9.5 supports now (cool, cool stuff, you should really have a look at it).
Ow and because of the many complaints about it, I removed the text-shadow from the text in the menu tabs.
-
200704 Sep
Posted in Browsers, CSS3 Previews, Interviews, Modules, W3C
Here’s the concluding part of our interview with Håkon (you can read the first part here).
-
Name the top five CSS3 features you’d like all major browsers to support in their next major release.
Here’s some of my favorites:
Also, we must not forget Generated content, and tables from CSS2.1. These are great features that still can’t be used due to lack of support from one browser.
-
Do you think there should be a Acid3 that focuses on CSS3 features that designs want supported as soon as possible?
Yes, I think it’s time for another Acid test — all major browsers but one (guess which one!) support Acid2 by now. I believe Acid3 should test CSS3 features that a critical mass of browsers can agree to implement. Also, it should probably test features from the upcoming HTML5 and the DOM.
-
Do you have a favourite designer who you admire their work, either from a design or technical respect?
I can’t give you one name. I often show designs from the CSS Zen garden when I give talks; I like many of them.
I can name two favorite fonts designers, though: Ray Larabie and Dieter Steffmann.
-
How do you think designers can get more involved with the CSS3 progress, to make sure features designed by designers themselves are added to the spec, instead of the features the spec writers might think are important? Is there a way this can be done without designers (many who don’t have much free time to spare) having to read through long mailing list histories and understanding a lot of very technical implementation details (I’m thinking such as having a appointed advisory board of designers for example that advise what features they want, and gather feedback from others, then the implementers can discuss this and come back with issues or start to draft specs for those features)?
We’ve always encouraged designers to be part of the CSS Working Group, and there has always been strong designer presence in www-style. Many of the choices we’ve made along the way are based on input from designers. For example, you wouldn’t find Backgrounds and borders on top of my list if it hadn’t been for designers. The idea of an advisory board may be a good one.
-
How do you feel about being nicknamed “the father of css”?
I often refer to CSS as my baby, and I’m fine with being called the father :-) It must be emphasized, though, that the child was shaped by a community. Bert Bos was the first to join the efforts, he came with a proposal of his own that we worked into CSS. Thomas Reardon and Chris Wilson of Microsoft were also influential in the time before the CSS WG and and the www-style mailing list was started.
-
What do you think of the Brazilian band CSS?
Wow. Right. Change of mindset. Music, right? When it comes to music, I prefer Opera!
-
-
200721 Aug
Posted in CSS3 Previews, Declarations
I was reading Veerle’s blog today; the excellent article A CSS styled table version 2, to be precise. All good, practical stuff, and well-presented as usual. But what stood out for me was the technique to stripe the table rows: either through classes, or Javascript.
Of course, both of those are valid techniques; but really, neither should be. It’s pretty easy to forget, when we see how far CSS-based design has come in the last few years, just how reliant on workarounds and tricks we are in order to perform what should be basic functions.
Presented below are some of those workarounds that I’d love to see consigned to the dustbin of history; not because they are bad – on the contrary, they are extremely inventive – but because CSS 3 should allow the effects to be replicated without the extra mark-up, script or code.
Tiger-striping on table rows
Whether done with background images, DOM scripting or just adding classes to the markup, none of the techniques are as easy as using the
nth-childpseudo-class:tr:nth-child(odd) { color: blue; }‘Sliding Doors’
Requires no extra mark-up but a lot of CSS jiggery-pokery, most of which could be avoided with multiple background images:
li { background: url('image0.png') no-repeat left top, url('image1.png') no-repeat right top; }Rounded corners
Which do you prefer: multiple lines of Javascript? Or a single line of CSS?
div { border-radius: 1.5em; }Drop shadows
Even the simplest solutions seem to rely on an extra image and plenty of CSS tweaks. CSS 3 resolves it with one declaration:
img { box-shadow: 10px 10px 5px; }Of course, the problem is that perennial one: lack of support. No modern browser currently supports all of the examples shown above, and it will be many years before we can stop using the workarounds altogether. But I do look forward to the time when they become a secondary consideration – and to what extensive use of the new declarations reveals in terms of creating new workarounds to future problems.
-
200725 Jul
Posted in Browsers, CSS3 Previews, Modules, W3C
Since the idea of CSS2.2 was raised, there’s been some discussion as to what it should encompass, who should be responsible for the spec, and what it should be called; here’s what I think:
First, it doesn’t matter what it’s called. Whether it’s referred to as CSS2.2, CSS2.1+, CSS3 Interim, or whatever, makes no difference. It doesn’t need to have a name at all; the important thing is that we have it.
Second, it doesn’t need to be an official recommendation from the W3C; in fact, it may be easier if it’s not. The optimal solution would be communication between developers and browser manufacturers, and – crucially – between the browser manufacturers themselves. What’s needed is an agreement as to which features are implemented, and to make sure those features are implemented in the same way; a de facto standard.
Finally, what feature should it include? For me, it has to be the elements which have already been implemented and tested in at least one browser for an amount of time sufficient for developers to have used them.
The most-requested feature is multiple background images; if you’re going to have that, background clip, origin and size would be wanted too. Border images would also be useful, as would an agreement on implementation of border radius.
Opacity, and with it RGBA and HSLA, box shadow, and text shadow would round off the decorative declarations.
Even if those few could be agreed on, a lot of workarounds could be avoided.
I would have said that multi-column layouts were less urgent, but as they are already part of the Gecko engine and about to be introduced in Safari 3, it seems that that should be part of the standard. Media queries would be pretty necessary as we move into the mobile era, too.
Nothing I’ve mentioned above would be unrealistic; most have already been implemented in at least two current or imminent browsers. As they are available, why are we being kept waiting before we can use them? Think of all the extraneous markup we could be freeing ourselves from!
Come on, browser makers: open up lines of communication and get talking to one another; float the ideas on your company blogs, see what your readers have to say. There’s a whole big community of developers who love to download nightly builds and test new features, and are hungry to improve their pages.
-
200710 Jul
Posted in Browsers, CSS3 Previews, Declarations, Modules, W3C
The Short Answer:
None of it.
The Slightly Longer Answer:
I’m in the process of updating the Preview area at the moment (sneak preview), and what’s immediately apparent is the low level of implementation of the new CSS 3 features across the major browsers. As IE6 is still the most widely-used browser, roughly 50% (and, slowly, falling) of the market has next to no CSS 3 support at all. A sobering thought.
With IE7 introducing support for attribute selectors, roughly 50% of the market can use those. You will still have to provide fall-back support for IE6, however, either with conditional comments or through graceful degradation.
Next most-widely implemented property is opacity; with support in all the key browsers other than IE, perhaps 25% of site visitors will see this effect if you use it. Again, make sure that your designs degrade gracefully if tempted to add this to your code.
After that, you can more or less forget it. The properties in the Backgrounds and Borders module have patchy implementation in browsers, and almost all use browser-specific prefixes, which you probably want to steer away from in a production environment as they are subject to change (see the border-radius conflict as a good example of why they are tricky to implement).
text-shadow should gain support from Safari 3 and Opera 9.5, but even being generous that’s only around 5-10% of the market. Most of the other properties have little or no cross-browser support.
What You Can Do About It:
Get behind Andy Budd’s ‘CSS 2.2′ idea. Think about it. If you have a blog, discuss it there. Write to browser manufacturers and the W3C. We’re putting together a campaign website to promote the idea, so get in touch with us and offer support.
We want – no, need – these new properties, to do away with many of the non-standard or non-semantic solutions we have to use today to provide complex solutions for simple problems. CSS 3 provides many of those solutions, but they won’t be implemented cross-browser until they become standard; that can be via the W3C, or a de facto standard agreed by browser manufacturers. But however that standard is made, it won’t happen unless there’s concerted pressure from the development community.
-
200709 Jul
I’ve written a number of posts about CSS3 on my personal blog, so when I was asked to write on CSS3.info I jumped at the chance. To get the quick disclaimer out of the way, my day job is working for Opera Software as their Chief Web Opener. Any thoughts are my own, and any use of CSS3 properties doesn’t imply that they will or will not be supported by Opera in an upcoming release, unless otherwise explicitly stated.
With that out of the way, I was discussing the difference between opacity and RGBA in the office, and thought that it would be useful to write an example showing what the later can be useful for. In the main part, using RGBA is different from opacity, as the transparency only applied to the property you are setting the colour of, while opacity sets the transparency of the entire element. For example, setting opacity on a
pelement will set text as well as the background colour to the setting chosen, while setting RGBA will only make the background colour transparent, and not the text, ifbackground-colorproperty is used. I decided that overlaying a text block over an image would show this quite well, so I’ve knocked up an example using this to style a figure contain within an article. This example can be found here.To mark-up the figure, I wrapped the
imgand thepcontaining the caption in adivelement. While this wasn’t strictly needed, I feel like the figure is a division of the page, and so give some semantic meaning and convenient grouping of the figure’s components. I gave it the class name offigureas suggested in Dan Cederholm’s blog post on marking up figures and Chris Messina’s post on a similar topic. I then added a class ofcaptionon the caption, to state explicitly what the element contains.The first important point to note when using CSS3 is that only the very latest browser versions support any given feature, if any do at all. Therefore as Peter points out in the previous post, it is important to use graceful degradation. this is especially important when using RGBA colour values, as browsers are instructed to ignore the CSS statement if it doesn’t understand the Alpha channel part. It doesn’t fallback to just using the Red Green and Blue channels. In the example used here, the figure caption has been set to red with a alpha channel value of 0.6, using
background-color: rgba(255, 0, 0, 0.6);. A value of 1 would mean the colour would be fully opaque, while 0 would be fully transparent. For browsers that don’t support RGBA, there would be no background colour at all, and the text would be illegible. To solve this, a regular background colour is given, in this casebackground-color: red;. This has to be included before the statement using RGBA, so that it will be overridden by browsers that do support RGB with Alpha channel.To get the caption to overlay the image, the paragraph in question was set to use
position: relative;, and givenleftandtopvalues that position the element in the correct position; in this case the bottom right corner of the image. A positivez-indexvalue was given to ensure that it was displayed above theimgelement. I was tempted to useemvalues for the sizing and placement of the caption and the padding/margin of the figure, but as the image uses pixels for it’s height and width, it made the cross browser placement of the caption inconsistent across the browsers tested (Opera, WebKit, Minefield). Even using pixels, Minefield (current nightly of Firefox 3) is 1 pixel out on the vertical placement compared to Opera and WebKit. I’m sure there is probably a better way to place the element than what I’ve used in this example.As this blog is about CSS3 I added a couple more features. I gave the caption a slight shadow (okay, not strictly CSS3) using
text-shadow: 2px 2px 2px black;(This works in Opera Kestrel and Safari) and gave the whole figure a slight 3D effect by specifying a shadow around it. This was done usingbox-shadow. In truth no browser supports this without prefixes but Safari 3 supports it using-webkit-box-shadow. I also initially added a CSS3 selector to style the first line of text in the article as bold, using.content p:first-of-type:first-line. Unfortunately Safari 3 currently has a bug where it will apply this to everypand not just the first one, while Firefox totally ignores it as it doesn’t support thefirst-of-typeselector. Safari will probably fix this bug before version 3 is released as I noticed they’ve just fixed a similar bug with usingp:first-of-type:first-letter, but as I can predict when the first paragraph will come in this example (after the figure) and it works across each of the three browsers I tested, I just settled on using.figure+p:first-line. If anyone has any questions comments or has any better way of doing things, then feel free to leave a comment.
-
200728 Jun
Posted in Browsers, CSS3 Previews, Declarations
Graceful degradation means that your Web site continues to operate even when viewed with less-than-optimal software in which advanced effects don’t work.
With CSS 3 so tantalisingly close (and yet so far away!), it’s fun to play around with some of the new cosmetic features. In fact, we can even start to implement them on websites – as long as provision is made for users with older browsers.
Here’s the markup:
<ul> <li><a href="">One</a></li> <li><a href="">Two</a></li> <li><a href="">Tre</a></li> <li><a href="">Qua</a></li> </ul>
The CSS is quite lengthy, so view the source of the example page and you’ll get some idea of what I’ve done.
If you’re using IE6, you’ll see just a row of plain, grey boxes which don’t animate when you mouse over them. IE7 and Opera users get a slightly better experience, with the text going white when hovered:
li:hover a { color: #fff; }
Firefox and Safari 2 users get it better still, with border-radius and multiple backgrounds respectively supplying curves to the tabs:
li { url('corner_fff_topleft.png') no-repeat top left, url('corner_fff_topright.png') no-repeat top right; -moz-border-radius-topleft: 25px; -moz-border-radius-topright: 25px; }
It’s when you get to Konqueror (and, presumably, Opera 9.5), however, the new styles really kick in; use of the
nth-childdeclaration allows for alternating colours, andtext-shadowgive a slight illusion of depth when hovered:li:nth-child(1n) { background-color: #9f9; } li:nth-child(1n):hover { background-color: #0c0; } li:nth-child(1n):hover a { text-shadow: 2px 2px 2px #000; } li:nth-child(2n) { background-color: #6f6; } li:nth-child(2n):hover { background-color: #090; }
This was a very quick and easy example, but I’m sure you can imagine much more creative uses for graceful degradation. It’s a useful technique if you have the time to implement it, and comes in very useful when trying to persuade people to upgrade to a better browser: “If you think that website looks good now, take a look at it on my computer!”
-
200722 Jun
Posted in Browsers, CSS3 Previews
Opera have just announced version 9.5 of their desktop browser, currently codenamed ‘Kestrel’ – and as you can see from the screenshot they’ve chosen, it passes the CSS 3 selectors test with flying colours!
They mention that CSS 3 support will be improved (text-shadow is provided as an example), as well as
superior SVG support
, and a new Javascript engine will allow better access to websites with wonky coding.This sounds like a really exciting release, and should give Opera the accolade of being the most CSS 3 compliant cross-platform browser. Weekly builds will be available shortly.
-
200719 Jun
Posted in CSS3 Previews, Declarations, Modules, W3C
With the release of Safari 3, there are now two browsers with (browser-specific) implementations of
border-radius; unfortunately, the two implementations are different. The problem is that there is an unresolved ambiguity in the CSS 3 working draft.The draft proposes four declarations, which describe the four corners of a block:
border-top-left-radius border-top-right-radius border-bottom-right-radius border-bottom-left-radius
Each of them should accept two values, which
define the radii of a quarter ellipse that defines the shape of the corner
; this allows for irregular curves (take a look at the diagram in the draft if you need clarification, or see this example of a box withborder-radius: 5px 20px, horribly rendered in Safari for Windows).Safari, with the prefix
-webkit-, accepts these. Mozilla, with the prefix-moz-(and differing declarations), accepts only a single value and, therefore, only regular curves.At first glance, it would appear that Mozilla are in the wrong; however, their implementation is due to the ambiguity I mentioned earlier.
This ambiguity comes about in the
border-radiusshorthand property; if you enter a double value in this you’d expect to apply the irregular curves to all four corners:border-radius: 5px 10px;
If you wanted to have four different irregular curves on the box, you’d have to provide eight values to the declaration:
border-radius: 5px 20px 10px 5px 10px 20px 20px 5px;
But what if you wanted to have two corners with one value, and two corners with a different value?
border-radius: 5px 10px 10px 20px;
The problem is that this could be confused for four corners with regular curves. In order to get around this, you’d still have to provide eight values:
border-radius: 5px 5px 10px 10px 10px 10px 20px 20px;
In fact, from the brief testing I’ve done (and I can’t find any documentation), it seems you can’t do any of that; unless I’m missing something, the shorthand declaration in Safari accepts only 1 or 2 values, to provide either regular or irregular curves which are applied to all four corners. If you want different irregular corners, you have to supply values to all four declarations:
border-top-left-radius: 5px 20px; border-top-right-radius: 10px 5px; border-bottom-right-radius: 10px 20px; border-bottom-left-radius: 20px 5px;
Mozilla avoid this by going against the spec and allowing only regular curves; so you can provide 1, 2, 3 or 4 values and it’s all perfectly clear.
This problem is down to interpretation of the draft. I personally think Mozilla’s non-standard solution is better – it’s less flexible, but easier to understand – but can’t blame the Safari team for following the standard in their implementation.
It will be interesting to see which comes out on top; in the meantime, if you want to use
border-radiusin your code the only way to get them to appear the same on both browsers is with a single value for four regular corners:-moz-border-radius: 10px; -webkit-border-radius: 10px;





