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 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

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 id="train"></div>
              
            
!

CSS

              
                // #divtober 11: Train
// a.singlediv.com/divtober2020

black(alpha)
  rgba(0,0,0,alpha)

white(alpha)
  rgba(255,255,255,alpha)

body
  // min-height: 400px
  height: 100vh
  position: relative
  background-color: mediumpurple
  text-align: center
  overflow: hidden

div
  position: absolute

  &:before,
  &:after
    display: block
    content: ''
    position: absolute

#train
  width: 60%
  height: 100%
  top: auto
  left: auto
  right: 0
  bottom: 0
  background-repeat: no-repeat,
                     no-repeat,
                     repeat-x,
                     repeat-x,
                     repeat-x,
                     repeat,
                     repeat,
                     repeat,
                     repeat,
                     repeat,
                     no-repeat
  background-image: linear-gradient(to right, #ccc  11em,
                                              #999  11em,
                                              #999  12em,
                                              transparent 12em),
                    linear-gradient(to bottom, crimson 20%,
                                               gold 20%,
                                               gold 40%,
                                               lightseagreen 40%,
                                               lightseagreen 60%,
                                               dodgerblue 60%,
                                               dodgerblue 80%,
                                               orchid 80%),
                    linear-gradient(to left, #aaa 2%, #555 2%),
                    linear-gradient(to left, #888 2%, #333 2%),
                    linear-gradient(to left, #444 2%, silver 2%),
                    radial-gradient(circle at 40% 20%, white(.4) .1em, white(0) .11em),
                    radial-gradient(circle at 80% 30%, white(.4) .1em, white(0) .11em),
                    radial-gradient(circle at 20% 60%, white(.4) .1em, white(0) .11em),
                    radial-gradient(circle at 60% 50%, white(.8) .1em, white(0) .11em),
                    radial-gradient(circle at 50% 50%, white(.6) .1em, white(0) .11em),
                    linear-gradient(black, black)
  background-size: 100% 100%,
                   100% 1.5em,
                   7em .5em,
                   7em 1.3em,
                   7em 3em,
                   50% 55%,
                   50% 60%,
                   50% 60%,
                   50% 60%,
                   90% 100%,
                   100% 100%
  background-position: 0 0,
                       right 0 bottom 1.8em,
                       right 2em bottom 5.9em,
                       right 2em bottom 5em,
                       right 2em bottom 3.8em,
                       9em 0,
                       9em 0,
                       9em 0,
                       9em 0,
                       9em 0,
                       0 0
  animation: train-2 1000ms infinite linear
  @media (prefers-reduced-motion)
    animation: none
  @media screen and (max-width: 700px)
    font-size: 12px
  @media screen and (max-width: 450px)
    width: 70%
    font-size: 10px
  @media screen and (min-width: 950px) and (min-height: 600px)
    font-size: 20px

  &:before
    width: 8em
    height: 15em
    left: 1em
    bottom: 0
    background-color: darkslateblue
    border-radius: 5em 5em 0 0
    box-shadow: inset 1.2em 0 0 white(.2)

  &:after
    width: 120%
    height: 100%
    right: 100%
    margin-right: -9em
    background-repeat: repeat-x
    background-image: radial-gradient(circle at 50% 100%, transparent 60%, saddlebrown 60.5%),
                      radial-gradient(circle at 50% 100%, transparent 60%, peru 60.5%),
                      linear-gradient(peru, peru),
                      linear-gradient(to left, transparent 20%,
                                               #555 20%,
                                               #555 30%,
                                               transparent 30%,
                                               transparent 40%,
                                               #555 40%,
                                               #555 50%,
                                               transparent 50%,
                                               transparent 60%,
                                               #555 60%,
                                               #555 70%,
                                               transparent 70%,
                                               transparent 80%,
                                               #555 80%,
                                               #555 90%,
                                               transparent 90%),
                      linear-gradient(to left, transparent 20%,
                                               #333 20%,
                                               #333 30%,
                                               transparent 30%,
                                               transparent 40%,
                                               #333 40%,
                                               #333 50%,
                                               transparent 50%,
                                               transparent 60%,
                                               #333 60%,
                                               #333 70%,
                                               transparent 70%,
                                               transparent 80%,
                                               #333 80%,
                                               #333 90%,
                                               transparent 90%),
                      linear-gradient(to left, transparent 10%, gold 10%),
                      linear-gradient(to left, transparent 10%, gold 10%),
                      linear-gradient(to left, transparent 10%, crimson 10%),
                      linear-gradient(to left, transparent 10%, #444 10%),
                      linear-gradient(to left, transparent 45%,
                                               #444 45%,
                                               #444 65%,
                                               transparent 65%),
                      radial-gradient(circle at  .7em 50%, #333 .4em, transparent .4em),
                      radial-gradient(circle at 1.6em 50%, #333 .4em, transparent .4em),
                      radial-gradient(circle at 5.5em 50%, #333 .4em, transparent .4em),
                      radial-gradient(circle at 4.6em 50%, #333 .4em, transparent .4em),
                      radial-gradient(circle at right 15em top 45%, lightyellow 3em, alpha(lightyellow,0) 3em),
                      linear-gradient(-50deg, slateblue 30%, transparent 30%),
                      linear-gradient(50deg, slateblue 40%, transparent 40%)
    background-size: 6em 3em, 6em 3em, 100% .4em,
                     7em .5em,
                     7em 1.2em,
                     7em .1em,
                     7em .1em,
                     7em 3em,
                     100% .2em,
                     7em .5em,
                     7em 2em,
                     7em 2em,
                     7em 2em,
                     7em 2em,
                     100% 35em,
                     100% 12em,
                     100% 10em
    background-position: 100% 100%, right -.5em bottom 0, right 0 bottom 3em,
                         left 10em bottom 5.6em,
                         left 10em bottom 4.9em,
                         left 10em bottom 6.5em,
                         left 10em bottom 4.5em,
                         left 10em bottom 3.8em,
                         left 0 bottom 3.8em,
                         left 10em bottom 3.6em,
                         left 10em bottom 2.7em,
                         left 10em bottom 2.7em,
                         left 10em bottom 2.7em,
                         left 10em bottom 2.7em,
                         0 100%,
                         right 9em bottom 0,
                         0 100%
    animation: train-1 1000ms infinite linear
    @media (prefers-reduced-motion)
      animation: none

@keyframes train-1
  from
    background-position: 100% 100%, right -.5em bottom 0, right 0 bottom 3em,
                         left 10em bottom 5.6em,
                         left 10em bottom 4.9em,
                         left 10em bottom 6.5em,
                         left 10em bottom 4.5em,
                         left 10em bottom 3.8em,
                         left 0 bottom 3.8em,
                         left 10em bottom 3.6em,
                         left 10em bottom 2.7em,
                         left 10em bottom 2.7em,
                         left 10em bottom 2.7em,
                         left 10em bottom 2.7em,
                         0 100%,
                         right 9em bottom 0,
                         0 100%
  to
    background-position: 100% 100%, right -.5em bottom 0, right 0 bottom 3em,
                         left 17em bottom 5.6em,
                         left 17em bottom 4.9em,
                         left 17em bottom 6.5em,
                         left 17em bottom 4.5em,
                         left 17em bottom 3.8em,
                         left 7em  bottom 3.8em,
                         left 17em bottom 3.6em,
                         left 17em bottom 2.7em,
                         left 17em bottom 2.7em,
                         left 17em bottom 2.7em,
                         left 17em bottom 2.7em,
                         0 100%,
                         right 9em bottom 0,
                         0 100%

@keyframes train-2
  from
    background-position: 0 0,
                         right 0 bottom 1.8em,
                         right 2em bottom 5.9em,
                         right 2em bottom 5em,
                         right 2em bottom 3.8em,
                         9em 0,
                         9em 0,
                         9em 0,
                         9em 0,
                         9em 0,
                         0 0
  to
    background-position: 0 0,
                         right 0 bottom 1.8em,
                         right -5em bottom 5.9em,
                         right -5em bottom 5em,
                         right -5em bottom 3.8em,
                         9em 0,
                         9em 0,
                         9em 0,
                         9em 0,
                         9em 0,
                         0 0
              
            
!

JS

              
                // @lynnandtonic
// a.singlediv.com

              
            
!
999px

Console