Oliver Ker Design

Hire Me

CSS3 media queries and transitions

To create the rotating ‘flower’ that I used on my new web design holding site I used some media queries that are all the rage at the moment and transitions so that the flower spins around when the browser is resized.

Olik

I have created a simple demo to demonstrate. (Must use a webkit browser)

Mark up the page with normal HTML

<html>
<head>
</head>
	<body>
		<img src="images/flower.png" alt="flower"/>
	</body>
</html>

Then to make the flower spin we use CSS.

body {
	background: #E6E7E8 ;
	margin: 0;
	padding: 0;
	position: relative;
}
img[alt=flower] {
	display: block;
	left: -300px; top: -000px;
	position: absolute;
	-webkit-transition-duration: 4s, 2s;
}
@media screen and (min-width: 700px)
{
img[alt=flower] {
	-webkit-transform: scale(1.00) rotate(450deg) translate(0px, 0px) skew(0deg, 0deg); transform-origin: 50% 50%;
	-webkit-transition-duration: 2s, 4s;
}
}

By giving the flower reverse instructions for when the browser goes past the 700 pixel wide threshold the transition is called into play.

, ,

Comments

  1. # Duane Laverick 564 days ago

    It was good to meet you at the open coffee morning today.

    Very cool, I really like it.

    I was looking at doing something similar, but with my logo.
    So every time you refreshed/resized the screen it would spin.

    Kind Regards,

    Duane :-)

  2. # Filipe Varela 562 days ago

    ahah, loved it!

    What a nice use of media queries and transitions, glad to see something fresh and original being done with such technology.

    -F

More posts

  1. Using iCloud for presentation iPads

    27 January 2012

    On a recent project we were tasked with creating a web app for a presentation...

    Keep Reading...

  2. Bit more information about your site

    17 January 2012

    I often get asked to look through existing websites to evaluate for new work. After...

    Keep Reading...

  3. Christmas shopping on the move

    14 November 2011

    As web designers, UX designers or what ever we call ourselves these days, we have...

    Keep Reading...

Archive