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="scene">
  <div class="road">
    <div class="crosswalk">
      <div class="path">
        <div class="person  guard  patrol">
          <div class="stop-sign">
            <span>Stop</span>
          </div>
        </div>
        <div class="person  patrol"></div>
      </div>
    </div>
  </div>
</div>

              
            
!

CSS

              
                $animation-duration: 5s;


body {
  overflow-x: hidden;
}


.scene {
  background-color: olivedrab;
  width: 100%;
  height: 100vh;
}

.road {
  background-color: black;
  background-image: linear-gradient(
    to bottom,
    white,
    white 25%,
    black 25%,
    black 75%,
    white 75%,
    white
  );
  background-position: center center;
  background-size: 1rem 15%;
  background-repeat: repeat-y;
  width: 60%;
  min-width: 16rem;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 auto;
  border-width: 0 2rem 0 2rem;
  border-style: solid;
  border-color: darkgray;
  outline-width: 0 0.125rem 0 0.125rem;
  outline-style: solid;
  outline-color: black;
}

.crosswalk {
  background-color: blue;
  background-image: linear-gradient(
    to right,
    black 0%,
    black 20%,
    white 20%,
    white 80%,
    black 80%,
    black 100%
  );
  background-repeat: x-repeat;
  background-size: 20% 100%;
  width: 100%;
  height: 30%;
  min-height: 16rem;
  position: relative;
  
  @media (max-height: 500px) {
    height: 50%;
  }
}

.path {
  width: 100vw;
  height: 100%;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.person {
  background-color: steelblue;
  width: 5rem;
  height: 20vh;
  min-height: 8rem;
  border: 0.125rem solid black;
  border-radius: 2.5rem 2.5rem 0.25rem 0.25rem;
  position: absolute;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  
  &.patrol {
    animation: patrol-person #{$animation-duration * 2} linear infinite;
  }
  
  @at-root {
    @keyframes patrol-person {
      0% {
        opacity: 0;
        left: -10%;
      }
      0.001% {
        opacity: 1;
        left: -10%;
      }
      10%, 51.25% {
        opacity: 1;
        left: 15%;
      }
      83.5%, 99.999% {
        opacity: 1;
        left: 110%;
      }
      100% {
        opacity: 0;
        left: 110%;
      }
    }
  }
}

.guard {
  background-color: goldenrod;
  top: auto;
  bottom: 5%;
  transform: translateX(-50%);
  z-index: 2;
  
  &.patrol {
    animation: patrol-guard $animation-duration linear infinite;
  }
  
  @at-root {
    @keyframes patrol-guard {
      // transitioning the `left` property is terrible, you shouldn’t do it
      0%, 2.5% {
        left: 15%;
      }
      50%, 52.5% {
        left: 85%;
      }
      100% {
        left: 15%;
      }
    }
  }
}

.stop-sign {
  background-color: white;
  color: white;
  width:  4em;
  height: 4em;
  position: absolute;
  top: 25%;
  left: 100%;
  line-height: 4;
  font-weight: bold;
  text-align: center;
  text-transform: uppercase;
  clip-path: polygon(
    30%    0%,
    70%    0%,
    100%  30%,
    100%  70%,
    70%  100%,
    30%  100%,
    0%    70%,
    0%    30%
  );
  transform: translateX(-50%);
  
  &::before {
    content: "";
    background-color: red;
    display: block;
    position: absolute;
    top:    0.125rem;
    right:  0.125rem;
    bottom: 0.125rem;
    left:   0.125rem;
    clip-path: polygon(
      30%    0%,
      70%    0%,
      100%  30%,
      100%  70%,
      70%  100%,
      30%  100%,
      0%    70%,
      0%    30%
    );
  }
  
  .patrol & {
    animation: patrol-stop-sign $animation-duration linear infinite;
  }
  
  @at-root {
    @keyframes patrol-stop-sign {
      0%, 50% {
        left: 100%;
        right: auto;
        transform: translateX(-50%);
      }
      50.001%, 100% {
        left: auto;
        right: 100%;
        transform: translateX(50%);
      }
    }
  }
  
  span {
    position: relative;
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console