Stiern

via Ad Packs

Enhancing Your Site with WebKit

WebKit is an open source browser engine. Apple uses WebKit in Safari, Mail, and other applications. Google’s Chrome browser, along with the S60 browser and the iPhone browser, is also built on WebKit. Some of the cool features of WebKit is transitions and transforms. With purely CSS you can create stunning animations. Your site will still work in other browsers, but the users with WebKit browsers will just get a slightly better experience.

Take for example Elliot Jay Stocks’ new website, elliotjaystocks.com. It is in it self a very beautiful website, but if you open it in e.g. Safari 4, it’s even more beautiful. When you hover your mouse over the images, the border will slowly fade into a lighter color. In non-WebKit browsers, it’ll just be a very sudden transition. This done solely by CSS.

Elliot Jay Stocks' new website

Elliot Jay Stocks' new website

Another example is Atebits’ website. Atebits is the company behind the Twitter app Tweetie. Let’s have a look at their front page:

Atebits' website

Atebits' website

That’s just beautiful, huh? Well, let’s dive into how we easily can add similar function to our own site.

The first property we have to learn is -webkit-transition. The -webkit-transition property is a shortcode for the three properties -webkit-transition-property, -webkit-transition-duration and -webkit-transition-timing-function.

We’ll probably learn this the best by having a look at an example, so here goes: We want to create a div that, when hovered, fades into another color. Here’s the code:

div {
  -webkit-transition: background-color, color 0.4s linear;
  background-color: #777777;
}
 
div:hover {
  background-color:#999999;
}

And here’s the example:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

This wasn’t so hard, was it? Now let’s move on to using the -webkit-transform property. It allows you to scale, rotate, translate, and skew the object. It even allows you to use matrices for advanced transformations. Let’s try to rotate and skew the div from before:

div {
  -webkit-transition: all 0.4s linear;
  background-color: #777777;
}
 
div:hover {
  -webkit-transform: scale(1.3) skew(3deg);
  background-color:#999999;
}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

This is just a little glimpse into what you can do with WebKit. Hopefully, you’ll find it useful.

i55iqj8amt

8 comments

Leave one yourself

  1. Thanks that is very unique post. Never heard about it

  2. nice post, thanks! keep posting…

  3. Wow.. That’s really neat; I’ve never seen these effects done by CSS before, just jQuery and JavaScript. I’d love to eventually use them – perhaps in the future. The skew is especially neat.

  4. Hi there,

    Thank you for the nice comments and suggestions. For your pleasure, I have removed the text shadowing in the body text. On my screen it was not an issue, but I sure don’t want anyone to not to be able to read the articles, so thank you very much.

  5. Nice article! Thank you for it. A little suggestion for your website. Everything looks pretty sweet ind here, the only problem for me, is actually reading the content of your page. The text shadow declared in nizzle.css : text-shadow: 0 1px 1px #555555 on line 19 makes it really complicated for me, at least with this monitor, to read the text. Maybe the contrast is just not high enough. Just my 2 cents. Keep on blogging.ffffffffffff

  6. Cool, some nice effects there. I’m having some trouble with your text shadow on the body copy of your site though, it makes reading the text harder.

  7. I’m stunned!
    I’ve never seen these effects before!! It works also on Chrome effectively. I think this is something I’ll be using on my future project :)
    Thanks!

Trackbacks

  1. Twitted by designbysnow

    December 29, 2009 at 9:36 pm

    [...] This post was Twitted by designbysnow [...]

Leave a comment

Required

Required (will not be published)

or Twitter URL

Some HTML allowed. Spam is not.