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

              
                .bus
  .body
    .top
      .windows
        each val in [1, 2, 3, 4, 5, 6]
          .window
      .sign
        .flag
          each val in [1, 2, 3, 4, 5]
            .line
        .text LONDON BUS
      .number 123
    .yellow-line
    .bottom
      .upper
      .lower
      .headlight
      .mirror
      .staircase
        .pole
        .handle
        .steps
          each val in [1, 2, 3, 4]
            .step
      .windows
        .window
          .steering-wheel T
        each val in [1, 2, 3, 4]
          .window
  .wheels
    .wheel
    .wheel
              
            
!

CSS

              
                $color-red: #f81e15;
$color-black: #26272d;
$color-blue: #9cd8f4;
$color-yellow: #f0c252;
$color-gray: #9c9c9c;

html, body {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: $color-blue;
  background-position: 270px -140px;
  background-size: 720px;
  background-repeat: none;
  font-family: 'Open Sans', sans-serif;
}

.bus {
  width: 560px;
  height: 325px;
  position: relative;
  
  .body {
    width: 100%;
    height: 100%;
    
    .top {
      background-color: $color-red;
      border-radius: 50px 50px 0 0;
      height: 140px;
      width: 100%;
      top: 0;
      position: absolute;
      
      .windows {
        display: flex;
        justify-content: space-between;
        position: absolute;
        width: 520px;
        top: 15px;
        left: 20px;

        .window {
          box-shadow: 
            0 0 0 3px rgba($color-black, 0.3), 
            inset -5px 5px 0 rgba($color-black, 0.1);
          background-image: linear-gradient(
            35deg, 
            $color-blue 0%,
            $color-blue 30%,
            lighten($color-blue, 5%) 30%,
            lighten($color-blue, 5%) 40%,
            $color-blue 40%,
            $color-blue 45%,
            lighten($color-blue, 5%) 45%,
            lighten($color-blue, 5%) 70%,
            $color-blue 70%,
          );
          width: 72px;
          height: 40px;
          border-radius: 8px;

          &:first-child {
            border-top-left-radius: 30px;
            width: 92px;
          }

          &:last-child {
            border-top-right-radius: 30px;
          }
        }
      }
    }
    
    .sign {
      display: flex;
      position: absolute;
      top: 73px;
      left: 20px;
      background-color: $color-gray;
      width: 435px;
      height: 50px;
      border-radius: 5px;
      box-shadow: 0 0 0 3px rgba($color-black, 0.3);
      overflow: hidden;
      
      .flag {
        position: relative;
        height: 100%;
        width: 105px;
        background-color: #212a8c;
        overflow: hidden;
        box-shadow: 3px 0 0 rgba($color-black, 0.3);
        
        .line {
          background-color: $color-red;
          position: absolute;
          left: -20%;
          width: 140%;
          height: 8px;
          border: 5px solid white;
          
          &:nth-child(1) {
            top: -20px;
            transform-origin: 0 0;
            transform: rotate(26deg)
          }
          
          &:nth-child(2) {
            bottom: -20px;
            transform-origin: 0 0;
            transform: rotate(-26deg);
          }
          
          &:nth-child(3) {
            top: 16px;
            height: 11px;
            border-width: 4px;
            transform-origin: 0 0;
          }
          
          &:nth-child(4) {
            left: -25px;
            height: 11px;
            border-width: 4px;
            transform: rotate(90deg);
          }
          
          &:nth-child(5) {
            top: 20px;
            height: 11px;
            border: none;
          }
        }
      }
      
      .text {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 1;
        font-size: 42px;
        letter-spacing: 2px;
        color: white;
      }
    }
    
    .number {
      position: absolute;
      top: 96px;
      right: 20px;
      color: white;
      background-color: $color-black;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 72px;
      height: 25px;
      border-radius: 5px;
      font-size: 20px;
      letter-spacing: 2px;
      box-shadow: 0 0 0 3px rgba($color-black, 0.3);
    }
    
    .yellow-line {
      width: 102%;
      height: 12px;
      position: absolute;
      top: 133px;
      left: -1%;
      background-image: linear-gradient(
        $color-yellow 0%, 
        $color-yellow 20%, 
        lighten($color-yellow, 20%) 20%,
        lighten($color-yellow, 20%) 45%,
        $color-yellow 50%
      );
      border-radius: 5px;
    }
    
    .bottom {
      position: absolute;
      top: 145px;
      width: 100%;
      
      .upper {
        position: absolute;
        background-color: $color-red;
        width: 520px;
        right: 0;
        height: 60px;
      }
      
      .lower {
        position: absolute;
        background-color: $color-red;
        width: 100%;
        height: 75px;
        top: 60px;
        border-bottom: 5px solid $color-black;
        border-radius: 50px/20px 0 0 0;
      }
      
      .headlight {
        position: absolute;
        width: 6px;
        height: 20px;
        background-color: $color-yellow;
        top: 100px;
        left: -3px;
        border-radius: 3px;
      }
      
      .mirror {
        position: absolute;
        width: 10px;
        height: 30px;
        background-color: $color-black;
        top: 5px;
        left: 7px;
        border-radius: 2px;
        
        &::before {
          content: '';
          position: absolute;
          border-left: 3px solid $color-black;
          border-bottom: 3px solid $color-black;
          border-radius: 0 0 0 4px;
          width: 5px;
          height: 15px;
          left: -5px;
          top: -6px;
        }
      }
      
      .staircase {
        position: absolute;
        background-color: darken($color-red, 10%);
        width: 70px;
        height: 130px;
        top: 5px;
        right: 0;
        border-left: 6px solid darken($color-red, 10%);
        border-radius: 30px 0 0 0;
        
        .pole {
          position: absolute;
          right: 23px;
          width: 7px;
          height: 100%;
          background-color: lighten($color-gray, 10%);
          z-index: 1;
        }
        
        .handle {
          position: absolute;
          border: 3px solid lighten($color-gray, 10%);
          border-left-color: transparent;
          border-radius: 5px;
          height: 40px;
          width: 5px;
          top: 30px;
          left: -8px;
          z-index: 1;
        }
        
        .steps .step {
          position: absolute;
          background-color: $color-red;
          border-top: 2px solid $color-gray;
          height: 20px;
          
          &:nth-child(1) {
            bottom: 0;
            width: 60px;
          }
          
          &:nth-child(2) {
            bottom: 22px;
            width: 50px;
          }
          
          &:nth-child(3) {
            bottom: 44px;
            width: 35px;
          }
          
          &:nth-child(4) {
            bottom: 66px;
            width: 15px;
          }
        }
      }
      
      .windows {
        display: flex;
        justify-content: space-between;
        position: absolute;
        width: 405px;
        top: 12px;
        left: 50px;

        .window {
          box-shadow: 
            0 0 0 3px rgba($color-black, 0.3), 
            inset -5px 5px 0 rgba($color-black, 0.1);
          background-image: linear-gradient(
            35deg, 
            $color-blue 0%,
            $color-blue 30%,
            lighten($color-blue, 5%) 30%,
            lighten($color-blue, 5%) 40%,
            $color-blue 40%,
            $color-blue 45%,
            lighten($color-blue, 5%) 45%,
            lighten($color-blue, 5%) 70%,
            $color-blue 70%,
          );
          width: 72px;
          height: 40px;
          border-radius: 8px;
          
          &:first-child {
            border-radius: 50px/0 15px 0 0;
            overflow: hidden;
            
            .steering-wheel {
              color: lighten($color-black, 20%);
              font-size: 50px;
              transform: rotate(50deg) translate(15px, 28px);
            }
          }
        }
      }
    }
  }
  
  .wheels {
    .wheel {
      width: 100px;
      height: 50px;
      position: absolute;
      background-color: lighten($color-black, 10%);
      border-radius: 30px/50px 50px 0 0;
      bottom: 40px;
      
      &::before {
        content: '';
        position: absolute;
        border-radius: 100%;
        background-image: radial-gradient(
          $color-red 0%,
          $color-red 20%,
          #797e77 20%,
          #797e77 37%,
          $color-red 37%,
          $color-red 43%,
          $color-black 43%
        );
        top: 5px;
        left: 7px;
        width: 85px;
        height: 85px;
      }
      
      &:first-child {
        left: 15px;
      }
      
      &:last-child {
        right: 85px;
      }
    }
  }
}
              
            
!

JS

              
                // A pure CSS London bus, based on Ekaterina
// Ushakova's design (https://www.123rf.com/photo_137888403_stock-vector-london-city-bus-on-blue-backgound-red-double-decker-bus-with-british-flag-on-it-side-view-vector-ill.html)
//
// I created this pure CSS bus as a way to
// improve my CSS skills. Every additional detail 
// introduces another challenge, and CSS offers 
// a variety of ways to overcome them.
              
            
!
999px

Console