CSS3: Resizable Elements

With CSS3, users will be able to resize specific elements on your pages, through the use of the “resize: ” property. The example below make a class of <div> called “resize” that the user will be able to scale.

div.resize {
border: 1px #00000 solid;
height: 100px;
overflow: auto;
resize: both;
width: 100px;
}

The “resize: ” property can be set to “horizontal”, “vertical” or in this case “both”, depending on which way you want the element to be resizeable. Note the “overflow: ” property set to auto, so that scrollbars will appear if the user resizes the element to a smaller size than the content needs. You can set the “overflow: ” property to hidden to clip any content in the middle.

You can also use the “resize: ” the property, in combination with “min-height: “, “max-height: “, “min-width: ” and “max-width: ” to constrain how the element can be resized.

I can only find support for this in Safari 3 so far, but I’m sure support for Firefox and others is round the corner. it’s worth noting that Safari has had resize support for <textarea> elements enabled by default for a while. Although useful (undersized <textarea> elements are a pain), it’s worth restricting the maximum height and width so as to not let users completely destroy your interfaces.

CSS3: Hue, Saturation and Lightness Colours

Not sure about the usefulness of this one but it’s worth knowing about. CSS3 will see the introduction of colour-values based on hue, saturation and lightness values – one of many ways of describing colours other than RGB. It requires a colour-value, from 0 to 360 which represents a position on a colour wheel (think 360 degrees of colour). A percentage saturation value will then show how saturated that colour is, and a percentage lightness value will vary it from black to white. So the following will produce a fully saturated, dark red:

<div style="background: hsl(0, 100%, 50%);"></div>

I don’t as yet see a real need for this apart from saving a little bit of time if you had been converting HSL colours to RGB. What would be more useful in my opinion would be direct support for CMYK colours, so that print-branding can be carried on to the Web with minimal conversion.

Support for HSL colours has been added to Firefox 3, Safari 3 and Opera 9.5.

CSS3: RGBA Semi-Transparent Colours

The upcoming CSS3 will see support for more complex colour values, including an alpha value. Using CSS2, a semi-transparent background has been a bit of a problem. You had the option of using a semi-transparent PNG image but this isn’t supported by IE6 without some Javascript modification. Alternatively, you could create a <div> tag, and set the opacity and filter (IE) properties to make it semi-transparent. The problem here is that the opacity is inherited so the contents of your <div> tag are faded as well. See our workaround here.

However, in CSS3, we can simply declare a <div> tag like this.

<div style="background: rgb(99, 00, 00, 0.8);"></div>

to create a div with a semi-transparent dark-red background. Any content inside the <div> tag would be rendered using full opacity. Problem solved. RGBA colours are already supported in Safari 3 and Firefox 3, which also support an alpha value for the HSL colours that they support.

Manage Your Box With Webmin

If you’re like me, and you’re getting used to managing everything from within your browser, you might want to look into Webmin. It’s a browser-based administration tool for your Linux box that can be used to accomplish various maintenance tasks. Among the arsenal of features are:

* User management including disk quotas
* Local partition, mounted filesystem and NFS exports info
* Process management
* Access to system logs files
* Editing of bootup scripts
* Add and remove rules from your firewall
* Squid, Samba, MySQL, PostgreSQL and Apache configuration

PHP 5.3 Release Candidate 1

The first PHP 5.3 release candidate hit the mirrors today. Here’s a quick rundown of the main features of this release:

Namespaces – As your PHP scripts grow larger and more complex, it can be difficult to keep track of which variables you’re using. This is worsened if you’re using additional libraries and scripts from other sources that you didn’t write yourself. PHP’s new namespaces aim to alleviate the problem by allowing you to group your variables into categories. No more hours spent trying to find which bit of code is overwriting your variables.

Late Static Binding – Here’s the problem, how do create a class that accesses method / properties that haven’t been initialised yet. Admittedly, a tough one without the use of late static bindings. Creating a class, you can access the properties and methods in that class using the self:: keyword. If you create a child that extends that class you can access the parent’s properties and methods using the parent:: keyword. But until now, you’ve been unable to access the child’s properties and methods from the parent class. This is because multiple children can be used to instantiate the parent. Late static bindings means that in addition to self:: and parent::, the static:: keyword now provides access to all parent and instantiating child properties / methods. Happy days!

Anonymous / Lambda Functions – graduates of Java and other object-orientated program will recognise this immediately. It’s the ability to create a function (for example, as a callback function), without having to give it a name. When a function requires a callback, rather than having to define a function and enter that name as the callback we can use the standard function() {} syntax to group a few statements together on-the-fly.

Native MySQL Library – the PHP team have written their own MySQL library for the 5.3 release. This new “native library” is under the same license terms as the PHP project, not MySQL AB’s license terms. This means MySQL support can now be bundled in the PHP by default. Being developed specifically to work with PHP has also lead to greater memory efficiency.

Phar – clean out your PHP directories and organise your applications that bit more by grouping them into Phars. Similar to Java’s Jar files, you can distribute entire apps in a compressed form. PHP will now recognise the phar::// URI scheme, so that you can include individual files from a Phar archive without extracting all the files.

Internet Explorer 8 – Document Compatibility Mode

IE8 is here and I already hate it. It comes with lots of new features for the user- I’m not an IE8 user so I won’t comment on them, time will tell whether they’re any use. What it lacks however are any real changes to the rendering engine. As suspected from experimenting with the Beta version, there’s some tweaks here and there, largely involving CSS2.1, which should have been implemented a long time ago. Very little of CSS3 has been implemented, aside from the more advanced selectors, most of which, to be fair, were available in IE7.

One thing that has changed is that the various Microsoft-specific CSS properties that have been introduced over the years have been renamed so they’re now all accessible with the prefix “-ms-”. Or are they? Well, they are in IE8’s Standards Mode. Similar to previous version of Internet Explorer, there is Standards mode (used when the HTML file has a proper <!doctype> declaration) and Quirks mode (used when it doesn’t have a <!doctype> declaration).

If you were confused before, prepare to be really confused because the Standards modes and Quirks modes are not consistent across Internet Explorer versions. IE8 Standards Mode will render differently to IE7 Standards Mode – I guess this only to be expected since they’ve added and removed support for various attributes.

This is where the “Document Compatibility Mode” comes into play. Say I have a HTML page, well-formed and tested on all current browsers including IE7. This page makes use of semi-transparent backgrounds, so I have the “filter: ” attribute set for Internet Explorer and the “opacity: ” attribute set for everything else. In IE8, suddenly, “filter :” no longer exists, instead replaced by “-ms-filter: “. So IE8 does not pick up on our “filter: ” attribute and does not support the CSS3 “opacity: ” attribute.

Brilliant! What do we do now? Do we add yet another CSS attribute to these selectors – essentially using three declarations to achieve one effect? Apparently not  - not when we have “Document Compatibility Mode”. Our <!doctype> declaration means that IE is rendering in IE8 Standards Mode but Microsoft have afforded us the possibility to use IE7 Standards Mode by including the following <meta> tag.

<meta http-equiv=”X-UA-Compatible” content=”IE-EmulateIE7″ />

I don’t understand this move. Microsoft’s site shouts about IE8 being the most standards-compliant release yet. But they give developers an easy way out by allowing them to keep their site in IE7 mode. Any developer will tell you that the bane of their life is dealing with large numbers of users that are still running IE6 so why would you want to restrict yourself to developing for IE7. We need progression – we need users and developers to move forward, otherwise the Web will sat in the same place forever.

CSS3: Opacity

Opacity has been the bug-bear for years of Web development. Is it now resolved? No. In fact, it’s getting worse. Firefox, Safari, Opera and any other browsers based around the WebKit or Gecko-rendering engine have supported the de facto CSS “opacity: ” property, taking a decimal value between 0 and 1 (1 being fully opaque).

However, Internet Explorer has stuck with it’s “filter: ” property, which invokes a DirectX filter that changes the opacity of an element. The “opacity: ” property is now a part of the CSS3 specification, and you would have thought Internet Explorer 8 would support it – it’s hardly difficult. IE8 does not support “opacity: ” and to frustrate you further, it’s new “standards mode” moves the “filter: ” property to “-ms-filter: “. Okay, so it’s best to move all these non-standard CSS declarations out of standards mode, but when you’re not replacing it with anything, you’re just creating further problems.

So in short, to ensure maximum compatibility from IE8 onwards, you should declare opacity three times:

opactity: 0.8;
filter: alpha(opacity=80);
-ms-filter: alpha(opacity=80);

Joy! What’s more, IE8 does not seem to support alpha values for colours in the form of RGBA or HSLA. Oh well, at least we got PNG transparency in IE7.

QT 4.5 and QT Creator 1.0

Nokia have released the first version of the QT toolkit since they took over Trolltech in June 2008. The new version of the toolkit that powers KDE is now available under the LGPL, allowing proprietary software to be built upon it without the need to then release that software under a similar license. This, combined with new support for the Mac OS X Cocoa framework, could see higher take-up from commercial software producers who want to develop cross-platform.

This version see enhanced support for the OpenDocument format and tight integration within the WebKit HTML-renderer. Want to create your own browser? Just drop in the WebKit component and you’re pretty much there.

Finally, Nokia have also announced version 1.0 of QT Creator, a new IDE for QT. Trumping the KDE project’s own KDevelop, the standard for many years, QT Creator is an advanced C++ editor, visual debugger, project manager and drag-and-drop based forms designer all rolled into one single app. One single app that is fully cross-platform, with binaries currently available for Ubuntu, XP, Vista and Mac OS X.