Paul Hayes

tag: 3d

Creating a sphere with 3D CSS

With CSS3’s 3D trans­forms it is pos­si­ble to cre­ate a sphere-like object, albeit with many ele­ments. Recently I’ve been look­ing at cre­at­ing applic­a­ble 3D carousels. These rely on posi­tion­ing pan­els in a cir­cle around a cen­tral point (ie. rota­tion about the Y-axis), I put these pan­els in an unordered list. A nat­ural exten­sion is to dupli­cate each <ul> and rotate about the X-axis, cre­at­ing a sphere.

Creating a tetrahedron with 3D CSS

A tri­an­gle can be cre­ated in CSS by manip­u­lat­ing the bor­ders of an ele­ment. Com­bin­ing four tri­an­gles in a 3D space using -webkit-transform, these can be posi­tioned to form a tetra­he­dron (or pyra­mid if you pre­fer). With CSS ani­ma­tions this can also spin.

Creating an animated 3D CSS cube using 3D transforms

A 3D cube can be cre­ated solely in CSS, with all six faces. Using JavaScript to detect key presses and update inline styles this cube can be intu­itively nav­i­gated. Last week WebKit included the much antic­i­pated (at least on my part) 3D trans­forms in its lat­est nightly build. It is now pos­si­ble to cre­ate all sorts of crazy three-dimensional and ani­mated user inter­faces; the power comes largely in -webkit-perspective and a num­ber of updated transforms–adapted to incor­po­rate the Z axis.