Words from Alejandro U. Alvarez
CSS
Articles about CSS…
Fast and dirty CSS trick for IE
Mar 11th
I actually think that we the developers need IE, it is like the bad guy in an action movie, the good guy wouldn't have a life without him, although sometimes you really wish it never existed! Haha just kidding, we all wish it didn't exist... But well, there are some times when we need something to work, we need it fast, and we just don't have time to care for the standards at that moment. For those times, we can use a simple trick like this:
Underscore to comment out lines
This is probably the simplest tip, you can use underscores preceding style definitions to set them as comments... for all good browsers out there, except of course IE. This way you can easily define specific IE rules by putting an underscore before the style.
#underscore{ width:300px; _width:320px; /* This rule is only for IE */ }
This way we can easily add a different width, padding, or anything to an element in order to "get it right"
The clean way:
Now we are not going to do that with every single rule we need fixed! When we are going to fix more things, it's much better to put the fixes in a different stylesheet, and link it using a conditional statement. Basically, we want only IE6 for example to use those fixes, how is that done?
<!--[if lte IE 6]> <link media="screen" rel="stylesheet" href="something.css" /> <![endif]-->
But this doesn't validate! We need to find a solution then, and it is not as hard as one could think
We are going to include that, inside another conditional comment, but this time inside one that is valid! So we would write it as follows:
<!--[if IE]><![if lte IE 6]><![endif]--> <link media="screen" rel="stylesheet" href="something.css" /> <!--[if IE]><![endif]><![endif]-->
Now it validates! We have achieved using valid conditional comments to do this! I will now explain a bit more about these and how they work:
Conditional comments at a glance
You're smart (I hope) So let's race through this, conditional comments allow you to tell the browser to use some parts of your html only if a specific version is running (Or not) Let me show you the options we have: (Please note that this is the html valid version for each of them)
- <!--[if IE]> To select Internet Explorer
- <!--[if IE]><![if !IE]> Only if the browser is not Internet Explorer
- <!--[if IE 5.0]> Only if it is Internet Explorer 5.01 (There are other options as well)
- <!--[if !IE 5.0]> To select for IE 5.5 or 6 or 7.0
We also have some keywords that will allow for more control:
- gt = Selects greater than
- lt = Selects less than
- gte = Selects greater than or equal to
- lte = Selects less than or equal to
- ! = Selects all but what the expression says (i.e. It negates the expression)
For more information on conditional comments check out this guide by Manfred Staudinger
Perfect jQuery UI rotating tabs
Oct 20th
Tabs are nice. They create a very elegant interface, and jQuery UI does this marvelously, here we have a little preview of this:

jQuery UI Tabs
How to do that?
Include the files
With jQuery and jQuery UI it is dead simple. First, load the JS libraries, I recommend using the hosted files at Google for jQuery:
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="path/to/jquery UI" type="text/javascript"></script>
Remember to include also the CSS files for the UI Theme! Otherwise the tabs won't seem to work!
The HTML for the tabs:
We need a little HTML for our tabs to work:
A wrapper, a few divs with the content, and an unordered list with the tabs:
<div id="tabs-rotate"> <ul> <li><a href="#tab1"><span>Tab 1</span></a></li> <li><a href="#tab2"><span>Tab 2</span></a></li> <li><a href="#tab3"><span>Tab 3</span></a></li> </ul> <div id="tab1">Tab 1 content</div> <div id="tab2">Tab 2 content</div> <div id="tab3">Tab 3 content</div> </div>
The JavaScript:
Now comes the cool part, basically we want to have tabs. But although tabs are nice, people may not realize there is more content, or they might be just too lazy to browse through it, so, why not rotate through the tabs?
jQuery UI does that by itself with a very simple commant, but it is not perfect! So we need to program our tabs to rotate, unless the mouse is over them. This way when a user is looking for a link, the tab will wait!
So here is how this is achieved:
$(document).ready(function(){ $("#tabs-rotate").tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 3000); $('#tabs-rotate').hover(function(){ $(this).tabs('rotate', 0, false); },function(){ $(this).tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 3000); } ); });
First we instruct jQuery UI to set up tabs in that div, and to rotate them. Then we use a hover event to control the rotation. On hover no rotation, and on out resume rotation.
See it in action
You can see it working on the DJs Music homepage
As with the best stuff, it's terribly simple
Hope you enjoy,
Alex
Stylish CSS trick for your Website
Oct 19th
Maybe a few of you noticed this on some websites, maybe some of you even use it.
Right now this works in Safari, Opera, and Konqueror and Firefox 3.x. (I think it doesn't work in Firefox 1 or 2, correct me if I'm wrong)
What I'm talking about is the text-shadow, wisely applied to your design, it can give an great touch of elegance to your site.
Here you have an example:

And here you have a coded example:
The code
The CSS for this is very simple, we will simply apply a slight text-shadow, of 1px with no blur, to the text:
.elegant{ text-shadow:#FFFFFF 0 1px; }
This effect works best with dark grey text over light grey background, and it is a very useful style for "2.0" designs.
Hope you enjoyed it!
Alex
Creating original website backgrounds
Dec 30th
This tutorial is all about creating beautiful backgrounds for website with a modern/stylish look, have you ever wondered how those curved shapes were created? Here is a preview of one I created for this tutorial:

Fyre sample image
The image is only 300x300px, I didn't want to make anything huge, since it was only a test. The program we will be using will work both under Linux and Windows (No support for Mac users yet), it is called Fyre.
So if you are using Windows, scroll down until you see the tab "07 February 2005 - 0.9 released" and there you'll find both a Windows installer and a Windows zip. I prefer the installer, it runs a bit faster, but it is up to you.
If you are using Linux, before you download it and compile it yourself go to Synaptic and get it from there. It is available at least in Ubuntu (Which is the one I am using right now), if you can't find it in the repositories then download the latest release from their website and compile it. It comes with handy instructions on the configuration, so it shouldn't be hard. (If you have no clue on how to compile/install linux programs use Google, although I'll tell you a fast version: If there is a file called Makefile go to the Terminal, browse to the folder where the files are (First you have to extract them from the .tar.bz or whatever filetype it is, and type >> make all, or >> make. It depends on the program)
Now that Fyre is intalled open it and you'll see a main window to the right with a preview, and to the left a column full of options. For our website, select a bigger width and height. 1000x1000 will do most times. Now play with the controls, center the result, adjust the zoom to fit exactly the canvas WITHOUT touching the corners, and then save it. I've had some issues saving some images, so I sometimes simply print the screen and then cut out the image with Gimp...
Now that you have it place it in the website's folder and simply set it as background. If you don't know how to use this CSS code:
body{ background:url('fyre_image.png') no-repeat top left; }
The top left can be changed to top center, top right... or bottom corners, although I think that top alignment is much better.
Hope this helped you