Inline input labels with animation

This last week I’ve been doing a lot of work making a new homepage that looks like twitters, as well as modifying some things on the rest of the site to try and give it a cohesive look. While most of the site is still on the to do like (it’s a fairly large site) the new homepage is done (you can see it at, no promises it hasn’t been changes as the owner has a copy of CSS Edit and it not afraid to use it) and I think it met the goal. One of my favorite (non specialized) features is the animated inline input labels. Because it’s a great, simple implementation I decided to post it here.

First, the input are formatted a very special way, don’t worry it’s basic and easy to implement. First, the input for firstname:


The input is obvious, as is the label, the last div, with the class .inputerror.firstname is some specific code for inline displayed error messages, I may make a post about them if there is any interest. The trick to this is the CSS, the div.inputbox is the thing that actually looks like the input, and the true input has no border or background. The label is moved over the input box. Because of this it’s important to have the label properly formatted with the for="" element pointing to the appropriate input field.

The CSS that makes that look right is below, it’s the code used in the example (link at bottom) as the code used on that site is more than a little messy (to many people playing around with it).


Obviously that has some styling for looks, which is fully changeable based on your individual implementation, the important stuff is the display, overflow, and the margin-top on the .inputbox label, as well as the previously mentioned background in the .inputbox input style. You’ll notice that the inputbox doesnt have a width or a height (except where limited by the actual input inside it). That because thats all set via the individual inputs so you can vary it from input to input depending on what will go in it (just like the example has set up).

The last bit is the scripting, in this case jquery was used, but it should be convertible to any other javascript library, or straight javascript itself, It’s only in jquery here because I use jquery for nearly everything because it’s fast, stable, and feature-full. In this case it’s a function called at load although it can be called in any as long is it’s sub-function tun on keyup and/or keydown.


What this scripting does is bind the sub-function keyupdown on both the keyup and keydown. The reason it’s done on both is because it’s more reliably in always running that it is when you just do on up or down. The first first checks if there is a value to the input, if not it will reanimate the label back in, with a simple fade in the case, but you do have full control over how it does it. Then, if there is something in the input it will fade it out, in this case by pushing it right while fading out. Once a label is completely faded out it is hidden so it won’t interfere with normal operation of the input box (like selecting or double clicking). It also makes it visible again before fading it back in.

All three parts put together make a nice animated inline label like the ones on the Inline input labels with animation example page. It’s been tested in IE and on mobile devices and seems to work fine albeit with slow or no animations on mobile devices. There was some weird graphical things in IE on the test site but I believe it was due to the font-weight and IE’s lack of fon’t smoothing that caused it.

If you’ve found a great use for this, or have an questions or would like some help with modifications or implementation on your specific site leave a comment below.

100% width text area with adjacent button

Long time to post, between being sick and doing a bunch of really boring coding work nothing of value to post has come up recently, until now. Last week I was working on a contract where they have the entire layout as a series of tables set to 100% width (I know tables, how retro). Anyway I was trying to do something I had done hundreds of times before on their site, a text area thats 100% wide (so it flexes with the width of the page) that has a button next to as (as opposed to below it like would naturally happen). After spending some time on it i figured it out and decided I would post it here on the weekend so I would always be able to find it. Come today and wouldn’t you know it I forgot how I did it, so I played around a bit and found a solution. It’s not the same as the one I used for them but the end effect is the same. First it requires you to but some code around your input (it’s never that simple), a mini example table is below.

Enter Text


The last 2 empty table cells are not important, there just there because thats the same style that the contract sets everything up with. Anyways as you can see you have to wrap the entire input in a div, then just the text area in a div. Another thing you have to do it give your button a width, I usually use 95px since it seems to fit the majority of buttons out there (after all buttons names are usually things like “Submit” or “Load” not “Press here to do the thing you want to do”). That width of the button, along with any margins or passing you add to it to make the format clean, as then added as right padding to the cell this div cluster is placed in so in this case 95+5 to make the final product look clean is a nice round 100px. That code there is paired with the css below (it’s normal CSS here but it works just as well being all inline).


That css code prevents wrapping and plays with margins (equal to the amount of padding above, button width + margin) to get a nice clean look when your done. The simplest way to description what it does it in throws the button off the end, outside of the box, but the box is made shorter (by the inline padding added to that cell) to compensate and move it look as if it’s in the box.

One thing to note, if your going to use jQuery to pull values from the box laters you probably want to avoid the child selector “>” to make it easier, just use a space as it acts as a simple inside selector going all the say down when looking for elements, in this example that text area could easily be selected with #(“table input[type=’text’]”).

You can see it on the worlds more boring example page here: 100% width text area with adjacent button.

I know this is a poor way to do this, and if I run across any of my old code that does it in a better way I’ll update according, but this effectively works and I can now at least reference this myself later, even if nobody else is ever helped by it. If you know of a better way to achieve the same thing please comment.

HTML5 Mulit-Upload

Now that I have some time to not work on something for someone or another I figure I’d post this.

Uploading multiple files at once used to be strictly in the realm of flash or required javascript to crate multiple upload forms as needed. The first method has the problems with the general incompatibility of flash. The second, well, it’s a very low tech method and limits you to selecting only one file per upload form, real pain.

It’s a two step problem, step one, the form:

Pretty standard form, all you gotta do is add the multiple="multiple" in there and add brakets ([]). Those brakets are the key to the next set, they tell PHP to make the file variable an array so it stacks the files up, instead of just replace the it with the next one (laving you with only the last file uploaded).

Next thing to do is tell PHP up handle the uploaded files one by one. This is pretty simple, heres a quick one.


First thing you have to do is get the number of files, I used the count() of the file size because every file has a size, but the same can be said for any $_FILES attribute, so they all work equally well. Using a similar method it’s easy to retrofit an old upload system (which was my original implementation) simple by adding it in the loop and adding the variable to the end of the $_FILES call and it all just works.

This information was surprising difficult to find (most searches returned flash based solutions) but implementation on the existing system (that used FTP to transfer uploaded files to another server and wrote information in multiple databases) was far simpler than any of the flashed based ones, and it’s small and compact which is an added bonus.

An example of the above code can be found here:

Edit 2/12/11 Changed the display for the “view uploads” page.

Edit 1/22/13 As requested I’ve made the source of the uploads page viewable here: