Archive for May, 2010
HTML5 Watch
Our Solar System in CSS3
Void (empty) elements and self-closing start tags in HTML
The syntax for void elements and self-closing tags is something most web authors get right. However, there are two types of mistakes that I see every now and then: using end tags on void elements and using self-closing start tags on elements that can have content.
Posted in (X)HTML, HTML 5, Quick Tips.
Our Solar System in CSS3
This is an attempt to recreate our solar system using CSS3 features such as border-radius, transforms and animations. The result is surprising and quite interesting.
These past few months I’ve been exploring CSS3, trying to learn some of it’s new features and getting a feel for which browsers support it. A few weeks back I put out my first experiment exploring @font-face and transforms. This time, I set out to experiment with border-radius, and what I thought was going to be a boring little project turned out to be quite interesting.
Our Solar System in Modern Browsers
Take a look for yourself, using only CSS and HTML I managed to create a small simulation of our solar system.
For a better experience please view it on Safari, under chrome the animations lag for some reason.
The Details
Orbits and planets are all created using border-radius, while the animation is done via –webkit animation properties and transform. Below are examples of the code used.
border-radius
ul.solarsystem li.sun {
width: 40px;
height: 40px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
Animations & Transforms
ul.solarsystem li {
-webkit-animation-iteration-count:infinite;
-webkit-animation-timing-function:linear;
-webkit-animation-name:orbit;
}
ul.solarsystem li.earth span {
-webkit-animation-iteration-count:infinite;
-webkit-animation-timing-function:linear;
-webkit-animation-name:moon;
}
ul.solarsystem li.mercury {-webkit-animation-duration:5s;}
ul.solarsystem li.venus {-webkit-animation-duration:8s;}
ul.solarsystem li.earth {-webkit-animation-duration:12s;}
ul.solarsystem li.earth span {-webkit-animation-duration:2s;}
ul.solarsystem li.mars {-webkit-animation-duration:20s;}
ul.solarsystem li.asteroids_meteorids {-webkit-animation-duration:50s;}
ul.solarsystem li.jupiter {-webkit-animation-duration:30s;}
ul.solarsystem li.saturn {-webkit-animation-duration:60s;}
ul.solarsystem li.uranus {-webkit-animation-duration:70s;}
ul.solarsystem li.neptune {-webkit-animation-duration:100s;}
ul.solarsystem li.pluto {-webkit-animation-duration:120s;}
@-webkit-keyframes orbit {
from { -webkit-transform:rotate(0deg) }
to { -webkit-transform:rotate(360deg) } }
Animations and transitions will only work on –webkit browsers, other modern browsers will display a static version of the solar system rendered using border-radius, with the exception of IE of course.
Internet Explorer’s Parallel Flat Universe:
Yep, in the eyes of Internet Explorer our universe is flat and boring.
So there you have it, I think it’s pretty impressive what we can accomplish with a few lines of CSS these days.
Oh, and yes… I kept Pluto ;-)
Internet Explorer market share now below 60 percent
It’s been a while since I talked about the market share of various browsers here. It seemed more important around six or seven years ago before Internet Explorer’s market share started to decrease from levels above 95%.
Back in those days, sites that were built exclusively for Internet Explorer and actively blocked visitors with newer browsers like Mozilla or Safari were pretty common. Nowadays they are rare, at least in my experience. I can’t remember the last time I visited a site that told me to go away because I wasn’t using IE.
Posted in Browsers.