css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <div id="stickers">

  <div class="sticker sticker-1">
    <div class="sticker-container">
      <div class="sticker-wrapper">
        <div class="sticker-clip">
          <div class="sticker-front"></div>
          <div class="sticker-back"></div>
        </div>
      </div>
    </div>
  </div>

  <div class="sticker sticker-2">
    <div class="sticker-container">
      <div class="sticker-wrapper">
        <div class="sticker-clip">
          <div class="sticker-front"></div>
          <div class="sticker-back"></div>
        </div>
      </div>
    </div>
  </div>

  <div class="sticker sticker-3">
    <div class="sticker-container">
      <div class="sticker-wrapper">
        <div class="sticker-clip">
          <div class="sticker-front"></div>
          <div class="sticker-back"></div>
        </div>
      </div>
    </div>
  </div>

  <div class="sticker sticker-4">
    <div class="sticker-container">
      <div class="sticker-wrapper">
        <div class="sticker-clip">
          <div class="sticker-front"></div>
          <div class="sticker-back"></div>
        </div>
      </div>
    </div>
  </div>

  <div class="sticker sticker-5">
    <div class="sticker-container">
      <div class="sticker-wrapper">
        <div class="sticker-clip">
          <div class="sticker-front"></div>
          <div class="sticker-back"></div>
        </div>
      </div>
    </div>
  </div>

  <div class="sticker sticker-6">
    <div class="sticker-container">
      <div class="sticker-wrapper">
        <div class="sticker-clip">
          <div class="sticker-front"></div>
          <div class="sticker-back"></div>
        </div>
      </div>
    </div>
  </div>

</div>
            
          
!
            
              @function pow($number, $exp)
  $value: 1
  @if $exp > 0
    @for $i from 1 through $exp
      $value: $value * $number
  @else if $exp < 0
    @for $i from 1 through -$exp
      $value: $value / $number
  @return $value

@function sqrt($r)
  $x0: 1
  $x1: $x0
  @for $i from 1 through 10
    $x1: $x0 - ($x0 * $x0 - abs($r)) / (2 * $x0)
    $x0: $x1
  @return $x1

@function fact($number)
  $value: 1
  @if $number > 0
    @for $i from 1 through $number
      $value: $value * $i
  @return $value

@function sign($i)
  $sign: if($i != 0, $i/abs($i), 1)
  @return $sign

@function pi()
  @return 3.14159265359

@function rad($angle)
  $unit: unit($angle)
  $unitless: $angle / ($angle * 0 + 1)
  @if $unit == deg
    $unitless: $unitless / 180 * pi()
  @return $unitless

@function sin($angle)
  $sin: 0
  $angle: rad($angle)
  @for $i from 0 through 10
    $sin: $sin + pow(-1, $i) * pow($angle, (2 * $i + 1)) / fact(2 * $i + 1)
  @return $sin

@function cos($angle)
  $cos: 0
  $angle: rad($angle)
  @for $i from 0 through 10
    $cos: $cos + pow(-1, $i) * pow($angle, 2 * $i) / fact(2 * $i)
  @return $cos

@function tan($angle)
  @return sin($angle) / cos($angle)

$threshold: pi() / 180 / 20

@function asin($z)
  $sum: 0
  $complement: false
  $sign: sign($z)
  $z: abs($z)
  @if $z > 1
    @warn 'illegal `#{$z}` value for function'
    @return false
  @if $z > sin(pi()/4)
    $complement: true
    $z: sqrt(1 - pow($z, 2))
  $term: $z
  $i: 0
  $k: 1
  @while $term > $threshold
    $sum: $sum + $term
    $i: $i + 1
    $k: $k*(2*$i - 1)/(2*$i)
    $j: 2*$i + 1
    $term: $k*pow($z, $j)/$j
  @return $sign * (if($complement, pi()/2 - $sum, $sum)) * 1rad

@function acos($z)
  @return pi() / 2rad - asin($z)

@function atan($z)
  @return asin($z/sqrt(1 + pow($z, 2)))
  
@mixin sticker-base()
  -webkit-tap-highlight-color: transparent

  *
    backface-visibility: hidden
    pointer-events: none

  .sticker-container
    position: relative
    transform-style: preserve-3d

  .sticker-wrapper
    position: absolute
    top: 0
    left: 0

  .sticker-clip
    position: absolute
    left: 0
    top: 0
    overflow: hidden

  .sticker-front, &-back
    position: absolute
    overflow: hidden
    pointer-events: all

  .sticker-front
    z-index: 1
    background:
      position: center
      size: 100% 100%
      repeat: no-repeat

  .sticker-back
    z-index: 2


@mixin sticker-style($foreground-color, $background-color, $image: null)
  .sticker-front
    background:
      color: $foreground-color
      @if $image != null
        image: url($image)

  .sticker-back
    background:
      color: $background-color


@mixin sticker-transition($speed, $easing)
  .sticker-clip
    transition: $speed $easing transform

  .sticker-front, .sticker-back
    transition: $speed $easing transform


@mixin sticker-init($width, $height, $border-radius: 0px, $peel: 0.5, $peel-angle: 45deg, $rotation: 0, $shadow: false, $hover: true)

  $smaller: $width
  @if $height < $smaller
    $smaller: $height
  @if $border-radius > ($smaller / 2)
    $border-radius: $smaller / 2

  $size: sqrt(pow($width/1px, 2) + pow($height/1px, 2)) * 1px
  $offset-top: ($size - $height)/2
  $offset-left: ($size - $width)/2

  width: $width
  height: $height

  .sticker-container
    width: $size
    height: $size
    top: - $offset-top
    left: - $offset-left
    transform: rotate($rotation)

  .sticker-wrapper
    width: $size
    height: $size
    transform: rotate($peel-angle)

  .sticker-clip
    width: $size
    height: $size

  .sticker-front, .sticker-back
    left: $offset-left
    top: $offset-top
    width: $width
    height: $height
    border-radius: $border-radius

  $rotation-angle-fix: 90deg - $peel-angle
  @if $peel-angle > 90
    $rotation-angle-fix: $peel-angle - 90deg
  @if $peel-angle < 0
    $rotation-angle-fix: $peel-angle + 90deg
  @if $peel-angle < -90
    $rotation-angle-fix: 270deg - $peel-angle

  $border-angle-fix: $peel-angle
  @if $peel-angle > 90
    $border-angle-fix: $peel-angle - 90deg
  @if $peel-angle < 0
    $border-angle-fix: $peel-angle - 90deg
  @if $peel-angle < -90
    $border-angle-fix: $peel-angle

  $diagonal-angle: atan($height/$width)
  $angle-fix: ($rotation-angle-fix) + $diagonal-angle
  $angle-fix-back: $peel-angle + 180deg
  $offset-diagonal-angle: ($size - (sin($angle-fix) * $size)) / 2
  $offset-border-radius: $border-radius * sqrt(2) - $border-radius
  $offset-border-radius: $offset-border-radius * sin($border-angle-fix * 2)
  $offset: $offset-diagonal-angle + $offset-border-radius
  $offset-back: $offset - $size
  $peel-translate: ($size - $offset * 2) * $peel

  .sticker-clip
    transform: translateX($offset)

  .sticker-front
    $x: -$offset * cos($peel-angle)
    $y: -$offset * sin($peel-angle)
    transform: rotate(-$peel-angle) translateX($x) translateY($y)

  .sticker-back
    $os: $offset-back
    $x: $os * cos($angle-fix-back)
    $y: $os * sin($angle-fix-back)
    transform: rotate($angle-fix-back) translateX($x) translateY(-$y)

  $activation: ':hover'
  @if $hover == false
    $activation: '.peeled'

  &#{$activation}
    .sticker-clip
      transform: translateX($offset + $peel-translate)

    .sticker-front
      $x: (- $offset - $peel-translate) * cos($peel-angle)
      $y: (- $offset - $peel-translate) * sin($peel-angle)
      transform: rotate(- $peel-angle) translateX($x) translateY($y)

    .sticker-back
      $os: $offset-back + $peel-translate
      $x: $os * cos($angle-fix-back)
      $y: $os * sin($angle-fix-back)
      transform: rotate($angle-fix-back) translateX($x) translateY(-$y)
      
      
// sticker-base()
// sticker-init(width, height, border-radius, peel-value, peel-angle, rotation, shadow, hover)
// sticker-transition(transition-speed, transition-timing-function)
// sticker-style(foreground-color, background-color, image)
// sticker-shadow(shadow-size, shadow-color, shadow-opacity)

html, body
  height: 100%
  width: 100%
  margin: 0
  padding: 0
  overflow: hidden
  font-family: sans-serif

#stickers
  background: #2c3e50
  height: 100%
  width: 100%
  overflow-x: hidden
  overflow-y: auto
  -webkit-overflow-scrolling: touch
  display: flex
  flex-direction: row
  flex-wrap: wrap
  justify-content: space-around
  align-items: center
  align-content: flex-start
  padding: 50px
  box-sizing: border-box

  .sticker
    flex: 0 0 auto
    margin: 50px
    @include sticker-base()
    @include sticker-transition(500ms, ease-in-out)

    &-1
      @include sticker-init(150px, 100px, 0, 0.5, 45deg, 0deg, true)
      @include sticker-style(#2ecc71, #27ae60)
        
    &-2
      @include sticker-init(150px, 100px, 20px, 0.4, 60deg, 0deg, true)
      @include sticker-style(#3498db, #2980b9)

    &-3
      @include sticker-init(120px, 120px, 0px, 0.2, 120deg, 0deg, true)
      @include sticker-style(#9b59b6, #8e44ad)

    &-4
      @include sticker-init(120px, 120px, 60px, 0.8, 120deg, 0deg, true)
      @include sticker-style(#e74c3c, #c0392b)

    &-5
      @include sticker-init(100px, 150px, 0px, 0.5, -20deg, 0deg, true)
      @include sticker-style(#1abc9c, #16a085)

    &-6
      @include sticker-init(100px, 150px, 50px, 0.8, 10deg, 0deg, true)
      @include sticker-style(#f1c40f, #f39c12)
            
          
!
            
              const stickers = document.querySelector('#stickers');
const sticker  = stickers.querySelectorAll('.sticker');

if ('ontouchstart' in window) {

  stickers.classList.add('touch');

  for (var i = 0; i < sticker.length; i++) {
    sticker[i].onclick = function() {
      for (var j =0; j < sticker.length; j++) {
        sticker[j].classList.remove('peeled');
      }
      this.classList.add('peeled');
    };
  }

} else {

  stickers.classList.add('hover');

}
            
          
!
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.
Loading ..................

Console