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 47 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 45 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

Archive