Tweet For Code #1

By  on  

You don't need a thousand lines of code to make a big difference in any coding language.  Oftentimes it's quite the opposite:  a few tiny code snippets can do a world of good and accomplish big things.  I asked my Twitter followers to tweet to me their favorite tiny snippets of code -- that's a bit difference to try to pack into 140 characters!  Here are my favorites from this round!

Vertically Centering Elements

Vertically centering elements is a massive pain, even 20 years into CSS' life. This snippet cures all of those issues:

border-box All the Things!

I've seen a lot of people mention applying this CSS globally. I've not done so but it's worth checking out.

View All Global Variables and Object Properties

I love this for (manually) checking for leaked global variables. Can also be used on other objects to get properties and methods.

Targeting Chrome

Targeting Chrome on mobile done with just CSS? Nice!

Viewing the Current State of an Object

Using console.log on objects which may change will throw you off. This snippet prints out the object and its values at the immediate state:

Emulate console.dir

If a given browser doesn't support console.dir, you can use this code snippet:

Prevent IE Stair Stepping

Internet Explorer's "stair stepping" effect -- we've all been there, we haven't always had a fix.

This is just the first TFC -- I'll be running these periodically over the year.  Great work to those who tweeted this round and I hope to get the same massive response next time!

Recent Features

  • By
    Create a CSS Cube

    CSS cubes really showcase what CSS has become over the years, evolving from simple color and dimension directives to a language capable of creating deep, creative visuals.  Add animation and you've got something really neat.  Unfortunately each CSS cube tutorial I've read is a bit...

  • By
    5 More HTML5 APIs You Didn’t Know Existed

    The HTML5 revolution has provided us some awesome JavaScript and HTML APIs.  Some are APIs we knew we've needed for years, others are cutting edge mobile and desktop helpers.  Regardless of API strength or purpose, anything to help us better do our job is a...

Incredible Demos

  • By
    CSS Triangles

    I was recently redesigning my website and wanted to create tooltips.  Making that was easy but I also wanted my tooltips to feature the a triangular pointer.  I'm a disaster when it comes to images and the prospect of needing to make an image for...

  • By
    Parallax Sound Waves Animating on Scroll

    Scrolling animations are fun. They are fun to create and fun to use. If you are tired of bootstrapping you might find playing with scrolling animations as a nice juicy refreshment in your dry front-end development career. Let's have a look how to create animating...

Discussion

  1. border-box! border-box! border-box!

    Easily one of my favorites.

  2. Christian

    Brian, with his vertical-align code should be nominated president of the world…

  3. Nice tweets! Good idea!

  4. Great idea Indeed and really cute tweet specially third one.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!