Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                %input{:type => "checkbox", :id => "btn"}
%label{:for => "btn", :class => "btn"}
  %span.unchecked Play!
  %span.checked Pause!

  -(1..160).each do |i|
        -(1..5).each do |j|


                @import 'compass/css3';

$w: .25em; // width of strip
$l: 5em; // length of strip
$n: 5; // number of sides, should match number of nodes in DOM
$m: 32; // number of rings on each torus side
$ratio: 2; // major radius/minor radius

$p: $n*$m; // should match number of nodes in DOM

$ca: 360deg/$n;
$riminor: ($l/2)/tan($ca/2);
$rcminor: ($l/2)/sin($ca/2);

$cam: 360deg/$p;
$rcmajor: $ratio*$rcminor;

@mixin sp($w, $h: $w) {
  margin: if($w == $h, -$w/2, -$h/2 (-$w/2));
  width: $w; height: $h;

html, body { height: 100%; }

body {
  overflow: hidden;
  margin: 0;
  perspective: 32em;
  background: dimgrey;

.torus, .torus *, .torus :before, .torus :after {
  box-sizing: border-box;
  position: absolute;
  top: 50%; left: 50%;
  transform-style: preserve-3d;

.torus { transform: rotateX(-45deg) rotateY(0deg); }

@keyframes rotmaj { 
  to { transform: rotateX(-45deg) rotateY(360deg); }

.ring--penta {
  @for $i from 0 to $p {
    $rcurr: $rcmajor/cos($i*$cam - (floor($i/$m) + .5)*$ca);
    &:nth-child(#{$i + 1}) {
      transform: rotateY($i*$cam) 

@keyframes rotmin { to { transform: rotate(360deg); } }

.strip {
  @include sp($w, $l);
  &:before, &:after {
    @include sp($w, $l);
    backface-visibility: hidden;
    transform: rotateY(-90deg);
    content: '';
  &:after {
    transform: rotateY(90deg);
  @for $i from 0 to $n {
    $c: hsl($i*360/$n, 100%, 65%);
    $c1: hsl(($i + 1)*360/$n, 100%, 65%);
    &:nth-child(#{$i + 1}) {
      transform: rotate($i*$ca) translate($riminor);
      &:before { background: rgba($c, .4); }
      &:after { background: linear-gradient($c, $c1); }

/* "play animation" button styles */
input[type=checkbox] { display: none }
.btn {
  overflow: hidden;
  position: absolute;
  z-index: 10;
  top: 1em; left: 50%;
  border-radius: .5em;
  box-shadow: 0 1px 0 black, 0 -1px 0 #96d1f8;
  margin: 0 -3.25em;
  opacity: .45;
  background: #65a9d7 linear-gradient(#3e779d, #65a9d7);
  color: white;
  font: 700 italic 1em/2.6 Georgia, serif;
  text-shadow: 0 1px 0 black;
  cursor: pointer;
  transition: .7s;
  &:hover { opacity: 1; }
.btn, .btn span { width: 6.5em; height: 2.6em; }
.btn span {
  position: absolute;
  text-align: center;
  transition: .5s;
.unchecked { top: 0; }
.checked { top: 100%; }
input[type=checkbox]:checked ~ .btn .unchecked { top: -100%; }
input[type=checkbox]:checked ~ .btn .checked { top: 0; }

/* in case anyone is wondering why I haven't used 
 * `animation-play-state`: Chrome Canary on Win 7 fucks up */
input[type=checkbox]:checked ~ .torus {
  animation: rotmaj 17.43s linear infinite;
input[type=checkbox]:checked ~ .torus .rotor {
  animation: rotmin 8.37s linear infinite;


                /* NO, there is NO JS, just a comment
Clicking the *Play!* button starts the animation. Needs support for `transform-style: preserve-3d` (so no IE, not even 11, sorry). Tested & works on Win 7 in Chrome 34 Canary, Chrome 32, Opera 19, Firefox 26 (choppy animation & not so great rendering - original version actually had twice the number of elements, but changed that due to how it behaved in FF). 

It's a torus ( with pentagonal rings whose centres are distributed along a hypocycloid ( with 5 cusps in the `xOz` plane. The pentagonal rings rotate and so does the torus itself.