Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

Auto Save

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.

HTML

              
                h1 Centering rotating CSS triangles
.demo
  .circle
    span Problem
    .triangle.naive
  .circle
    span A solution
    .triangle.centred
  p Hover the triangles to see the box being rotated.
  p.l CSS rotations centre on bounding boxes, so triangles are not rotated on their centroid.
  p.l Using the <code>:after</code> pseudo-element for the triangle, the original element may be given a height and width to create bounding box centred around the triangle's centroid.
              
            
!

CSS

              
                @import compass

$PI: 3.1415926
$rad: 128px
$margin: 32px
$track: 3px
$edge: $rad * sin(2 * $PI / 3) / sin($PI / 6)
$height: $edge * sin(2 * $PI / 3)
$font: 18px
$col: #547
$period: 8s

body
  background: $col
  font: #{$font} / 1em sans-serif
  color: lighten($col, 40%)
  text-align: center

h1
  font-weight: normal
  font-size: 1.5em

.l
  text-align: left
  line-height: 1.3em

.demo
  margin: 2.5em auto
  width: ($rad + $track) * 4 + $margin

.circle
  margin-bottom: 1em
  float: left
  width: $rad * 2
  height: $rad * 2
  border: $track dashed lighten($col, 30%)
  border-radius: $rad
  &:first-of-type
    margin-right: $margin
  span
    display: block
    margin: -$font * 1.5 0 $font/2

=triangle
  height: 0
  width: 0
  border-style: solid
  border-width: 0 $edge/2 $height
  border-color: transparent transparent rgba(255, 255, 255, 0.2)

.triangle
  -webkit-animation: spin $period linear infinite
  -moz-animation: spin $period linear infinite
  animation: spin $period linear infinite
  &:hover
    background: rgba(0, 0, 0, 0.2)

.naive
  margin-left: $rad - $edge/2
  +triangle

.centred
  position: relative
  height: $rad * 2
  width: $rad * 2
  &:after
    content: ""
    position: absolute
    top: 0
    left: $rad - $edge/2
    +triangle

@-webkit-keyframes spin
  to
    -webkit-transform: rotate(360deg)
@-moz-keyframes spin
  to
    -moz-transform: rotate(360deg)
@keyframes spin
  to
    transform: rotate(360deg)

              
            
!

JS

              
                
              
            
!
999px

Console