cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              div.container
  div.background.night
    div.overlay
    div.sun
    div.moon
    div.stars
    div.cloud.top
    div.cloud.mid
    div.cloud.bot-backup
    div.forest-top
    div.forest-bot
  div.text
    h3 Night mode on
    p Toggle switch to change lighting
    input(type="checkbox").cbx.hidden#unchecked
    label(for="unchecked").lbl
      
    
  
            
          
!
            
              @import "compass";
$container-width:350px;
$container-height:400px;

body{
  background:#d4e3e6;
}

.container{
  position:absolute;
  top:50%;
  left:50%;
  margin-top:-$container-height/2; 
  margin-left:-$container-width/2;
  
  width:$container-width;
  background:#fff;
  @include border-radius(10px);
  
  .background{
    height:252px;
    position:relative;
    overflow:hidden;
    @include border-radius(10px 10px 0 0);
    @include transition-property(background);
    @include transition-duration(2s);
    
    .forest-top svg polygon,
    .forest-bot svg path{
      @include transition-property(fill);
      @include transition-duration(2s);
    }
    
    .stars{
      opacity:0;
      @include transition-property(opacity);
      @include transition-duration(2s);
    }
    
    &.day{
      background-color:#0aceff;
      
      .cloud{
        opacity:1
      }
      
      .forest-top svg polygon{
        fill:#149cbf;
      }
      
      .forest-bot svg path{
        fill:#0d87a3;
      }
    }
    
    &.night{
      background-color:#172a60;
      
      .forest-top svg polygon{
        fill:#18214f;
      }
      
      .forest-bot svg path{
        fill:#172a60;
      }
      
      .cloud{
        opacity:0.2
      }
      
      .stars{
        opacity:0.28;
      }
    }
    
    .overlay{
      position:absolute;
      z-index:10;
      width:0;
      height:0;
      border-top:252px solid rgba(255, 255, 255, 0.06);
      border-right:350px solid transparent;
    }
    
    .cloud{
      position:absolute;
      width:100px;
      @include transition-property(opacity);
      @include transition-duration(2s);
      
      &.top{
        top:-15px;
        left:0px;
      }
      &.top-backup{
        top:-15px;
        left:-100px;
      }
      
      &.mid{
        top:35px;
        left:200px;
      }
      
      &.mid-backup{
        top:35px;
        left:0px;
      }
      
      &.bot{
        top:65px;
        left:-30px;
      }
      &.bot-backup{
        top:65px;
        left:-230px;
      }
    }
    
    .forest-top,
    .forest-bot{
      position:absolute;
      bottom:-3px;
    }
    .forest-top{
      bottom:10px;
    }
    
    .moon,.sun{ 
      bottom:-40px; 
    }
    
    .moon{
      position:absolute;
      left:10px;
      transform: scale(0.6, 1);
      
      svg{
        width:150px;
        height:150px;
      }
    }
    
    .sun{
      position:absolute;
      left:10px;
      
      svg{
        width:150px;
        height:150px;
      }
    }
  }
  
  .text{
    text-align:center;
    color:#172a60;
    font-family: Arial,"Helvetica Neue",Helvetica,sans-serif;
    h3{
      font-size:26px;
      font-weight:bold;
      padding-top:35px;
    } 
    p{
      color:#69738e;
      font-size:13px;
      margin-top:10px;
    }
    
    .lbl{
      position: relative;
      display: block;
      height: 34px;
      width: 65px;
      background: #dfe4f5;
      border-radius: 100px;
      cursor: pointer;
      transition: all 0.3s ease;
      margin: 30px auto;
      
      &:after{
        position: absolute;
        right: -4px;
        top: -2px;
        display: block;
        width: 38px;
        height: 38px;
        border-radius: 30px;
        background: #172a60;
        @include box-shadow(0px 2px 5px -1px rgba(23,42,96,0.75));
        content: '';
        transition: all 0.3s ease;
      }
      
      &:active:after{
        transform: scale(1.15, 0.85);
      }
    }
    .cbx:checked ~ label {
      background: #cee7ed; 
    }

    .cbx:checked ~ label:after {
      left: -2px;
      background: #00ccff;
      @include box-shadow(0px 2px 5px -1px rgba(0,204,255,0.75));
    }

    .hidden { display: none; }
  }
  
  &.day{
    h3{
      color:#0c8faf;
    }
    
  }
}
            
          
!
            
              $(function() {
  var svg = [
    'https://dl.dropboxusercontent.com/s/wppjkl1mapcofi1/egles_dark.svg?dl=0',
    'https://dl.dropboxusercontent.com/s/1tluv1o16bu8dv1/egles_light.svg?dl=0',
    'https://dl.dropboxusercontent.com/s/df61ibt6hk9mk2z/sun.svg',
    'https://dl.dropboxusercontent.com/s/z5nkite52l21gnn/moon.svg',
    'https://dl.dropboxusercontent.com/s/a24sxazrdbnkn4q/stars.svg?dl=0',
    'https://dl.dropboxusercontent.com/s/n329j6mekvr5mec/makonis_1.svg?dl=0',
    'https://dl.dropboxusercontent.com/s/jpd6t207d4s1ozo/makonis_2.svg?dl=0'
  ];

  $('.forest-top').load(svg[0]);
  $('.forest-bot').load(svg[1]);
  $('.sun').load(svg[2]);
  $('.moon').load(svg[3]);
  $('.stars').load(svg[4]);

  $('.cloud.top, .cloud.top-backup').load(svg[5]);
  $('.cloud.mid, .cloud.mid-backup').load(svg[6]);
  $('.cloud.bot, .cloud.bot-backup').load(svg[5]);

  TweenLite.to($('.moon'), 0, {
    bottom: '40px',
    scale: 1
  });

  $('.cloud').each(function() {
    tweenCloud($(this));
  });

  $('.cbx').bind('change', function() {
    daySwap();
  });
});

tweenCloud = function($cloud) {
  var offset = $cloud.position(),
    speed = (450 - offset.left) / 10;
  TweenLite.to($cloud, speed, {
    left: '350px',
    onComplete: function() {
      TweenLite.to($cloud, 0, {
        left: '-300px',
        //top: 120 - (Math.random() * 140) + 'px',
        onComplete: function() {
          tweenCloud($cloud)
        }
      })
    }
  })

}

daySwap = function() {
  var $cbx = $('.cbx'),
    day = !$cbx.is(':checked'),
    $sun = $('.sun'),
    $moon = $('.moon'),
    bounceSize = 75,
    visiblePosition = 45;
  $('h3').fadeOut(function() {
    $(this).text(((day) ? 'Night' : 'Day') + ' mode on').fadeIn();
  $('.container').toggleClass('day');
  $('.background').removeClass((day) ? 'day' : 'night').addClass((day) ? 'night' : 'day');
  });

  TweenLite.to((day) ? $sun : $moon, 0.2, {
    bottom: bounceSize + 'px',
    scaleX: 0.6,
    ease: Bounce.easeOut
  });
  TweenLite.to((day) ? $sun : $moon, 0.3, {
    bottom: '-40px',
    ease: Power4.easeOut,
    delay: 0.2
  });
  TweenLite.to((day) ? $sun : $moon, 0, {
    scaleX: 1
  })

  TweenLite.to((day) ? $moon : $sun, 0.5, {
    bottom: bounceSize + 'px',
    scaleX: 1,
    scaleY: 0.6,
    ease: Bounce.easeOut,
    delay: 1
  });
  TweenLite.to((day) ? $moon : $sun, 0.4, {
    bottom: visiblePosition + 'px',
    ease: Bounce.easeOut,
    scaleY: 1,
    delay: 1.2
  });

}
            
          
!
999px
Loading ..................

Console