Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

HTML

              
                <div class="background">
  <div class="clouds">
    <div class="cloud"></div>
    <div class="cloud"></div>
    <div class="cloud"></div>
    <div class="cloud"></div>
  </div>
  <div class="behind-building">
    <div class="buildings">
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
    </div>
    <div class="buildings">
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
    </div>
    <div class="buildings">
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
    </div>
  </div>
  <div class="front-building">
    <div class="buildings">
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
    </div>
    <div class="buildings">
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
    </div>
    <div class="buildings">
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
      <div class="building"></div>
    </div>
  </div>
  <div class="trees">
    <div class="tree"></div>
    <div class="tree"></div>
    <div class="tree"></div>
    <div class="tree"></div>
  </div>
  <div class="road">
    <div class="marking"></div>
  </div>
  <div class="sidewalk">
  </div>
  <div class="car">
    <div class="top">
      <div class="window"></div>
    </div>
    <div class="bottom">
      <div class="front-torch"></div>
      <div class="door"></div>
      <div class="rear-torch"></div>
    </div>
    <div class="wheels">
      <div class="left"></div>
      <div class="right"></div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                // ********** VARIABLES START ********** //

// ***** BACKGROUND START ***** //
$background-color: linear-gradient(#80bdff 15%, #b3d7ff 30%);
$background-width: 600px;
$background-height: 400px;
// ***** BACKGROUND START ***** //

// ***** ROAD START ***** //
$road-color: #2f2f2f;
$road-width: 1000px;
$road-height: 100px;
$road-animation-time: 4s;
// ***** ROAD END ***** //

// ***** SIDEWALK START ***** //
$sidewalk-color: #b1b1b1;
$sidewalk-width: 600px;
$sidewalk-height: 25px;
// ***** SIDEWALK END ***** //

// ***** TREE START ***** //
$trees-width: 800px;
$trees-height: 55px;
$trees-bottom-pos: $road-height + $sidewalk-height + ($sidewalk-height * 0.1);
$tree-width: $trees-width / 4;
$tree-height: $trees-height;
$tree-leaves-color: #19a800;
$tree-trunk-color: #5e2f00;
$tree-animation-time: 12s;
// ***** TREE END ***** //

// ***** FRONT BUILDING START ***** //
$front-building-width: 1300px;
$front-building-height: 150px;
$front-building-bottom-pos: $trees-bottom-pos;
$front-building-color: #707070;
$front-building-window-color: #2f2f2f;
$front-building-window-width: (($front-building-width / 4) * 0.2) * 0.26;
$front-building-window-height: ($front-building-height * 0.6) * 0.2;
$front-building-window-top: $front-building-window-height * 0.2;
$front-building-window-left: $front-building-window-width * 0.24;
$front-building-window-top-guide: floor($front-building-window-height + $front-building-window-top);
$front-building-window-left-guide: floor($front-building-window-width + $front-building-window-left);
$front-building-animation-time: 25s;
// ***** FRONT BUILDING END ***** //

// ***** BEHIND BUILDING START ***** //
$behind-building-width: 1200px;
$behind-building-height: 200px;
$behind-building-bottom-pos: $trees-bottom-pos;
$behind-building-color: #633fe8;
$behind-building-animation-time: 50s;
// ***** BEHIND BUILDING END ***** //

// ***** CLOUD START ***** //
$cloud-width: 1000px;
$cloud-height: 100px;
$cloud-color: white;
$cloud-animation-time: 75s;
// ***** CLOUD END ***** //

// ***** CAR START ***** //
$car-color: #d20f0f;
$car-width: 150px;
$car-height: 70px;
$car-top-width: $car-width * 55px / 100px;
$car-top-height: $car-height * 35px / 100px;
$car-top-left: $car-width * 27px / 100px;
$car-bottom-width: $car-width * 93px / 100px;
$car-bottom-height: $car-height * 50px / 100px;
$car-wheel-size: $car-bottom-height * 0.85;
$car-animation-time: 0.35s;
// ***** CAR END ***** //

// ********** VARIABLES END ********** //

// ********** STYLES START ********** //

* {
  padding: 0;
  margin: 0;
}

// ***** BACKGROUND START ***** //
.background {
  background: $background-color;
  width: $background-width;
  height: $background-height;
  overflow: hidden;
  position: relative;
}
// ***** BACKGROUND END ***** //

// ***** ROAD START ***** //
.road {
  background: $road-color;
  width: $road-width;
  height: $road-height;
  position: absolute;
  bottom: 0;
  left: $road-width * -0.02;
  animation: road $road-animation-time infinite linear;
  > .marking {
    width: $road-width;
    height: $road-height * 0.33;
    border-bottom: dashed ($road-height * 0.055) white;
  }
}
// ***** ROAD END ***** //

// ***** SIDEWALK START ***** //
.sidewalk {
  background: $sidewalk-color;
  width: $sidewalk-width;
  height: $sidewalk-height;
  border-bottom: solid ($sidewalk-height * 0.1) darken($sidewalk-color, 25%);
  position: absolute;
  bottom: $road-height;
}
// ***** SIDEWALK EfrontND ***** //

// ***** TREES START ***** //
.trees {
  width: $trees-width;
  height: $trees-height;
  position: absolute;
  bottom: $trees-bottom-pos;
  > .tree {
    width: $tree-width;
    height: $tree-height;
    position: absolute;
    bottom: 0;
    &:before {
      content: "";
      background: $tree-leaves-color;
      width: $tree-width * 0.175;
      height: $trees-height * 0.67;
      position: absolute;
      left: ($tree-width * 0.25) - ($tree-width * 0.175 / 2);
      border-radius: 50%;
      box-shadow: floor(($tree-width * 0.6) - ($tree-width * 0.175 / 2)) 0 $tree-leaves-color;
    }
    &:after {
      content: "";
      background: $tree-trunk-color;
      width: $tree-width * 0.035;
      height: $trees-height * 0.33;
      position: absolute;
      bottom: 0;
      left: ($tree-width * 0.25) - ($tree-width * 0.035 / 2);
      box-shadow: floor(($tree-width * 0.53) - ($tree-width * 0.035 / 2)) 0 $tree-trunk-color;
    }
  }
  @for $i from 0 through 3 {
    > .tree:nth-child(#{$i + 1}) {
      left: $i * $tree-width;
      animation: tree-#{$i + 1} $tree-animation-time infinite linear;
    }
  }
}
// ***** TREES END ***** //

// ***** FRONT BUILDING START ***** //
@function front-building-windows($count_i, $count_j) {
  $building-window: 0 0 $front-building-window-color;
  @for $i from 0 through $count_i - 1 {
    @for $j from 0 through $count_j - 1 {
      $building-window:
        $building-window,
        #{$i * $front-building-window-left-guide} #{$j * $front-building-window-top-guide} $front-building-window-color;
    }
  }
  @return $building-window;
}
@mixin front-building-style($attr_i, $attr_j, $front-building-add-width, $front-building-add-height, $front-building-add-left) {
  background: $front-building-color;
  width: ($front-building-width / 4) * $front-building-add-width;
  height: $front-building-height * $front-building-add-height;
  position: absolute;
  bottom: 0;
  left: ($front-building-width / 4) * $front-building-add-left;
  &:before,
  &:after {
    content: "";
    background: $front-building-window-color;
    position: absolute;
  }
  &:before {
    width: $front-building-window-width;
    height: $front-building-window-height;
    top: $front-building-window-top;
    left: $front-building-window-left;
    box-shadow: front-building-windows($attr_i, $attr_j);
  }
  &:after {
    width: (($front-building-width / 4) * $front-building-add-width) - ($front-building-window-left * 2);
    height: $front-building-window-height + ($front-building-window-left);
    bottom: 0;
    left: $front-building-window-left;
  }
}
.front-building {
  width: $front-building-width;
  height: $front-building-height;
  position: absolute;
  bottom: $front-building-bottom-pos;
  > .buildings {
    width: $front-building-width / 4;
    height: $front-building-height;
    position: absolute;
    bottom: 0;
    > .building:nth-child(1) {
      @include front-building-style(3, 6, 0.2, 1, 0.215);
    }
    > .building:nth-child(2) {
      @include front-building-style(3, 3, 0.2, 0.6, 0.01);
    }
    > .building:nth-child(3) {
      @include front-building-style(4, 4, 0.265, 0.75, 0.73);
    }
    > .building:nth-child(4) {
      @include front-building-style(5, 2, 0.32, 0.45, 0.42);
    }
  }
  @for $i from 0 through 2 {
    > .buildings:nth-child(#{$i + 1}) {
      left: $i * ($front-building-width / 4);
    }
    > .buildings:nth-child(#{$i + 1}) {
      animation: front-building-#{$i + 1} $front-building-animation-time infinite linear;
    }
  }
}
// ***** FRONT BUILDING END ***** //

// ***** BEHIND BUILDING START ***** //
@mixin behind-building-style($behind-building-add-width, $behind-building-add-height, $front-building-add-left) {
  background: $behind-building-color;
  width: $behind-building-width * $behind-building-add-width;
  height: $behind-building-height * $behind-building-add-height;
  position: absolute;
  bottom: 0;
  left: ($behind-building-width / 4) * $front-building-add-left;
}
.behind-building {
  width: $behind-building-width;
  height: $behind-building-height;
  position: absolute;
  bottom: $behind-building-bottom-pos;
  > .buildings {
    width: $behind-building-width / 4;
    height: $behind-building-height;
    position: absolute;
    bottom: 0;
    & > .building:nth-child(1) {
      @include behind-building-style(0.04, 1, 0.02);
    }
    & > .building:nth-child(2) {
      @include behind-building-style(0.06, 0.6, 0.19);
    }
    & > .building:nth-child(3) {
      @include behind-building-style(0.03, 0.7, 0.43);
      &:after {
        $behind-building-triangle-height: floor($behind-building-width * 0.047);
        $behind-building-triangle-width: floor($behind-building-height * 0.01);
        content: "";
        border-top: none;
        border-bottom: solid $behind-building-triangle-height $behind-building-color;
        border-left: solid $behind-building-triangle-width transparent;
        border-right: solid $behind-building-triangle-width transparent;
        position: absolute;
        top: floor($behind-building-width * 0.047) * -1;
        left: ($behind-building-width * 0.03 / 2) - ($behind-building-triangle-width / 2);
      }
    }
    & > .building:nth-child(4) {
      @include behind-building-style(0.04, 0.8, 0.6);
      &:after {
        $behind-building-roof-width: floor($behind-building-width * 0.02);
        $behind-building-roof-height: floor($behind-building-height * 0.1);
        content: "";
        background: $behind-building-color;
        width: $behind-building-roof-width;
        height: $behind-building-roof-height;
        position: absolute;
        top: floor($behind-building-height * 0.1) * -1;
        left: ($behind-building-roof-width / 2);
      }
    }
    & > .building:nth-child(5) {
      @include behind-building-style(0.055, 0.6, 0.77);
    }
  }
  @for $i from 0 through 2 {
    > .buildings:nth-child(#{$i + 1}) {
      left: $i * ($behind-building-width / 4);
    }
    > .buildings:nth-child(#{$i + 1}) {
      animation: behind-building-#{$i + 1} $behind-building-animation-time infinite linear;
    }
  }
}
// ***** BEHIND BUILDING END ***** //

// ***** CLOUD START ***** //
.clouds {
  width: $cloud-width;
  height: $cloud-height;
  position: absolute;
  > .cloud {
    width: $cloud-width / 4;
    height: $cloud-height;
    position: absolute;
    &:before,
    &:after {
      content: "";
      background: $cloud-color;
      position: absolute;
      border-radius: 50%;
    }
    &:before {
      width: $cloud-width / 4 * 0.4;
      height: $cloud-height * 0.4;
      top: $cloud-height * 0.2;
      left: ($cloud-width / 4) * 0.1;
    }
    &:after {
      width: $cloud-width / 4 * 0.3;
      height: $cloud-height * 0.3;
      bottom: $cloud-height * 0.2;
      right: ($cloud-width / 4) * 0.1;
    }
  }
  @for $i from 0 through 3 {
    > .cloud:nth-child(#{$i + 1}) {
      left: $i * ($cloud-width / 4);
    }
    > .cloud:nth-child(#{$i + 1}) {
      animation: cloud-#{$i + 1} $cloud-animation-time infinite linear;
    }
  }
}
// ***** CLOUD END ***** //

// ***** CAR START ***** //
.car {
  width: $car-width;
  height: $car-height;
  position: absolute;
  bottom: $background-height * 0.025;
  left: ($background-width / 2) - ($car-width / 2);
  animation: car $car-animation-time infinite linear;
  > .top {
    background: $car-color;
    width: $car-top-width;
    height: $car-top-height;
    position: absolute;
    top: 0;
    left: $car-top-left;
    border-top-left-radius: ($car-top-height * 2) ($car-top-width * 0.4);
    border-top-right-radius: ($car-top-height * 2) ($car-top-width * 0.4);
    > .window {
      background: #a3b9ff;
      width: $car-top-width * 0.85;
      height: $car-top-height * 0.8;
      position: absolute;
      bottom: 0;
      left: ($car-top-width - ($car-top-width * 0.85)) / 2;
      border-top-left-radius: ($car-top-height * 0.8 * 1.8) ($car-top-width * 0.85 * 0.3);
      border-top-right-radius: ($car-top-height * 0.8 * 1.8) ($car-top-width * 0.85 * 0.3);
      &:after {
        content: "";
        background: $car-color;
        width: ($car-top-width - ($car-top-width * 0.85)) / 2;
        height: $car-top-height * 0.8;
        position: absolute;
        left: $car-top-width * 0.85 * 0.65;
      }
    }
  }
  > .bottom {
    background: $car-color;
    width: $car-bottom-width;
    height: $car-bottom-height;
    position: absolute;
    top: $car-top-height;
    left: ($car-width - $car-bottom-width) / 2;
    border-top-left-radius: $car-bottom-width * 0.12;
    border-top-right-radius: ($car-bottom-height * 0.5) ($car-bottom-width * 0.12);
    &:after {
      content: "";
      background: $car-color;
      width: $car-width;
      height: $car-bottom-height * 0.2;
      position: absolute;
      bottom: 0;
      left: ($car-width - $car-bottom-width) / 2 * -1;
      border-radius: $car-bottom-height * 0.2;
    }
    > .door {
      background: darken($car-color, 20%);
      width: $car-bottom-width * 0.075;
      height: $car-bottom-height * 0.125;
      border-radius: $car-bottom-height * 0.125;
      position: absolute;
      top: $car-bottom-height * 0.175;
      left: $car-bottom-width * 0.55;
    }
    > .front-torch {
      background: #c4b400;
      width: ($car-width - $car-bottom-width) / 2;
      height: $car-width - $car-bottom-width;
      position: absolute;
      top: $car-bottom-height * 0.45;
      left: ($car-width - $car-bottom-width) / 2 * -1;
      border-radius: ($car-width - $car-bottom-width) 0 0 ($car-width - $car-bottom-width) #{"/"} ($car-width - $car-bottom-width);
    }
    > .rear-torch {
      background: lighten($car-color, 5%);
      width: ($car-width - $car-bottom-width) / 2;
      height: $car-bottom-height * 0.20;
      position: absolute;
      top: $car-bottom-height * 0.55;
      right: ($car-width - $car-bottom-width) / 2 * -1;
      border-radius: 0 ($car-bottom-height * 0.20) ($car-bottom-height * 0.20) 0 #{"/"} ($car-bottom-height * 0.20);
    }
  }
  > .wheels {
    > div {
      background: #111111;
      width: $car-wheel-size;
      height: $car-wheel-size;
      position: absolute;
      bottom: 0;
      border-radius: $car-wheel-size;
      &:after {
        content: "";
        background: #e2e2e2;
        width: $car-wheel-size * 0.65;
        height: $car-wheel-size * 0.65;
        position: absolute;
        top: ($car-wheel-size - ($car-wheel-size * 0.65)) / 2;
        left: ($car-wheel-size - ($car-wheel-size * 0.65)) / 2;
        border-radius: $car-wheel-size * 0.7;
      }
      &.left {
        left: $car-bottom-width * 0.17;
      }
      &.right {
        right: $car-bottom-width * 0.12;
      }
    }
  }
}
// ***** CAR END ***** //

// ********** STYLES END ********** //

// ********** KEYFRAMES START ********** //

// ***** DIV-3 START ***** //
@mixin div-3($width, $name) {
  @keyframes #{$name}-1 {
    0%, 100% {
      left: 0;
    }
    66.66% {
      left: $width / 2;
    }
    66.67% {
      left: $width / 4 * -1;
    }
  }
  @keyframes #{$name}-2 {
    0%, 100% {
      left: $width / 4;
    }
    33.32% {
      left: $width / 2;
    }
    33.33% {
      left: $width / 4 * -1;
    }
  }
  @keyframes #{$name}-3 {
    0%, 100% {
      left: $width / 4 * -1;
    }
    99.99% {
      left: $width / 2;
    }
  }
}
// ***** DIV-3 END ***** //

// **** DIV-4 START **** //
@mixin div-4($width, $name) {
  @keyframes #{$name}-1 {
    0% {
      left: 0;
    }
    74.99% {
      left: $width * 0.75;
    }
    75% {
      left: $width / 4 * -1;
    }
    100% {
      left: 0;
    }
  }
  @keyframes #{$name}-2 {
    0%, 100% {
      left: $width / 4;
    }
    49.99% {
      left: $width * 0.75;
    }
    50% {
      left: $width / 4 * -1;
    }
  }
  @keyframes #{$name}-3 {
    0%, 100% {
      left: $width / 2;
    }
    24.99% {
      left: $width * 0.75;
    }
    25% {
      left: $width / 4 * -1;
    }
  }
  @keyframes #{$name}-4 {
    0%, 100% {
      left: $width / 4 * -1;
    }
    99.99% {
      left: $width * 0.75;
    }
  }
}
// **** DIV-4 END **** //

// ***** CAR START ***** //
@keyframes car {
  50% {
    height: $car-height * 1.05;
    bottom: $background-height * 0.035;
  }
}
// ***** CAR END ***** //

// ***** ROAD START ***** //
@keyframes road {
  0% {
    left: $road-width * -0.4;
  }
}
// ***** ROAD END ***** //

// ***** TREE START ***** //
@include div-4($trees-width, 'tree');
// ***** TREE END ***** //

// ***** FRONT BUILDING START ***** //
@include div-3($behind-building-width, 'front-building');
// ***** FRONT BUILDING END ***** //

// ***** BEHIND BUILDING START ***** //
@include div-3($behind-building-width, 'behind-building');
// ***** BEHIND BUILDING END ***** //

// ***** CLOUD START ***** //
@include div-4($cloud-width, 'cloud');
// ***** CLOUD END ***** //

// ********** KEYFRAMES END ********** //

              
            
!

JS

              
                
              
            
!
999px

Console