123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              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.
            
          
!
            
              @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)

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console