Form Fields and Width: 100%

One thing I ran into when I first started doing responsive design was the misalignment of input and textarea boxes. For example, you’d think the following code would be self-explanatory.

input,
textarea {
     border: 1px solid #ccc;
     -moz-border-radius: 2px;
     border-radius: 2px;
     width: 100%;
}

But it’s not. You end up with a small overlap, exhibited in the image below.

You can see that the textarea is slightly wider than the input[type="text"] box. What causes this? In Chrome, there is 2px of padding on a <textarea> element, and 1px of padding on a <input> element. You could just set your own padding amount and then adjust the width. The problem with that is I don’t want to set the padding to a static amount (say 0.2em) and then have the width be a percentage.

Instead, set the box-sizing property to border-box:

input,
textarea {
     -moz-box-sizing: border-box;
     -webkit-box-sizing: border-box;
     box-sizing: border-box;
     border: 1px solid #ccc;
     -moz-border-radius: 2px;
     border-radius: 2px;
     width: 100%;
}

Now, when the width is set to 100%, the padding is disregarded in the calculation of the width.

Boom! Easy. Support is good too – IE8 and up – as long as you use vendor prefixes. So next time you’re running into width issues on a responsive design, just throw in box-sizing.

Australian Open Finals

You can guarantee that the Rolling Lab team is watching the Australian Open Finals right now. You should be too. This is great theatre.

View As Analog

One of the most productive things I’ve ever done is to set the clock on my computer to analog. Top-right corner of OS X, click on the time, and then click ‘View As Analog’. If you happen to look up, you get a general sense of the time, but not the specific time. This has helped so much. Instead of realizing it’s 2 AM and then thinking it’s bed-time, I look up and get a general idea of the time and continue working.

Twitter Shortcode

Here’s a shortcode I made recently for a WordPress site. It stores the retrieved data as a transient, minimizing HTTP requests and subsequently reducing page load times for users. Feel free to use it. Post any comments if you want clarification.

// Twitter Feed
add_shortcode( 'twitter', 'rl_twitter_feed' );
function rl_twitter_feed( $atts ) {

	// Attributes
	if( isset( $atts['handle'] ) )
		$handle = $atts['handle'];

	// Check transients
	$body = get_transient( 'rl_twitter_data' );
	if( empty( $body ) ) {
		$twitter_url = 'http://twitter.com/statuses/user_timeline/' . $handle . '.json?count=3';
		$data = wp_remote_get( $twitter_url );
		$body = wp_remote_retrieve_body( $data );

		if( empty( $body ) )
			return false;

		$body = json_decode( $body, true );
		set_transient( 'rl_twitter_data', $body, 300 );
	}

	//Begin Output
	$output = '<aside class="twitter-feed"><ul>';

	// Work with decoded data
	foreach( $body as $tweet ) {
		$output .= '<li>';
		$output .= '<p><span class="twitter-meta"><time datetime="' . date( 'Y-m-d', strtotime( $tweet['created_at'] ) ) . '">' . date( 'd F, Y', strtotime( $tweet['created_at'] ) ) . '</time>';
		$output .= ' - <a href="http://twitter.com/' . $tweet['user']['screen_name'] . '">@' . $tweet['user']['screen_name'] . '</a></span>';
		$output .= $tweet['text'];
		$output .= '<span class="twitter-source">Via ' . $tweet['source'] . '</span>';
		$output .= '</p></li>';
	}
	$output .= '</ul></aside>';

	return $output;
}

Show Me My Opponent

I’ve been listening to D.Veloped’s Work: Party mixtape… and this. DIFF is 1:18:56 of non-stop fun. My favourite section is around 54:22, “Big Stuntin’”. It’s awesome.

The best thing about long mashups like this is I can just go to town on a problem. If I haven’t solved it by the time the song is over, then I suck and should just quit. This has yet to fail.

If You Only Knew The Power Of the Dark-Side

This song is amazing. Tim sent me the link to it when I was in Vancouver last-week. It’s a dubstep remix of ‘Binary Sun’ – the Jedi theme from the Star Wars movies. There are three voice samples that are absolutely amazing. The last one, right after the bridge is Vader.

I’d be lying if I said that I haven’t listened to it a hundred times by now.

Work: Party

Here’s what I’m listening to while building the new site. It took me a couple listens, but now I’m really digging it. The lead in from The Childish Games to Fly Like An Eagle is amazing.

Time keeps on slippin’ slippin’ slippin’ into the future

123