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

              
                header
  h1 
    span.header-subtitile PURE CSS
    p.header-title Parallel park
main
  .car-line.park
    .car.car-red
      .car-front
      .car-middle
      .car-back
    span.vacancy.passo1 
    .car.car-blue
      .car-front
      .car-middle
      .car-back
  .car-line    
     input.passo1 type='checkbox' id="passo1"    
     input.passo2 type='checkbox' id="passo2" 
     input.passo3 type='checkbox' id="passo3"     
     input.passo4 type='checkbox' id='passo4'
     .car.car-silver
       .car-front
       .car-middle
       .car-back     
     .breadcrumbs.breadcrumbs-flat       
       label.passo1-label for="passo1" start
       label.passo2-label for="passo2" step2
       label.passo3-label for="passo3" step 3
       label.passo4-label for="passo4" finish
     .congrats
       h2.congrats-title Congratulations!
       h3.congrats-subtitle You are now a parallel park master.
       p.congrats-text
         a.congrats-link href="https://twitter.com/intent/tweet?text=I liked this 'Pure CSS Parallel Park' on @codepen. Take a look and discover how to parallel park. https://codepen.io/teles/full/gbKeLR" target="_blank" title="And show them how to perfect parallel park." Share this pen with your friends on twitter. &#8599;
    


              
            
!

CSS

              
                @import compass

@import url(https://fonts.googleapis.com/css?family=Montserrat:400,700)
@import url(https://fonts.googleapis.com/css?family=Lato)

input      
  display: none

main
  position: relative
  
header
  h1
    font-family: Montserrat, 'sans-serif'
    font-size: 45px    
    text-align: center
    color: #34495e
    .header-subtitile
      font-size: .35em
      margin-bottom: 5px
      position: relative
      &:before,
      &:after
        content: ''
        position: absolute
        width: 25%
        height: 2px
        top: 50%
        margin-top: -1px
        background-color: #34495e
      &:before      
        left: -35%
      &:after
        right: -35%
    .header-title        
      margin-top: 0
        

// ------------------------------------------ |
// Variáveis                                  |
// -------------------------------------------|

$color-car: #b6bec3
$color-car-blue: #3498db
$color-car-red: #e74c3c
$color-car-silver: silver
$color-glasses: #495d65
$height-car: 125px
$width-car: 285px
$margin-left-car: 40px
$padding-park: 20px
$margin-left-passo1: ($width-car + $margin-left-car) * 2 + $padding-park

html
  padding: 0 20px
  background-color: #ecf0f1
  font-family: 'Lato', sans-serif
main
  width: ($width-car + $margin-left-car) * 3 + 10px
  display: block  
  background-color: hsl(0, 8%, 90%)  
  min-height: 500px
  margin: 0 auto
.park
  background-color: hsl(0, 8%, 85)    
  padding: $padding-park
  position: relative  
  border-top: 2px solid #fff
  @include box-shadow(0px -20px 0px #c4baba)
  margin-top: 50px
  &:before,
  &:after
    content: ''
    position: absolute
    height: 100%
    border-left: 2px dashed #fff
    width: 2px
    top: 0px
  &:before  
    left: $width-car + $padding-park + 10px
  &:after  
    left: $width-car * 2 + $padding-park * 2 + $margin-left-car
// ------------------------------------------ |
// Extends - placeholder                      |
// Estilos comuns para elementos simétricos   |
// -------------------------------------------|

// retrovisores
%commons-retrovisor
  content: ''
  width: 12px
  height: 12px
  background-color: inherit    
  right: 80px
  position: absolute  

// farois  
%commons-farol
  content: ''
  width: 20px
  height: 10px
  background-color: yellow
  position: absolute      
  top: 70px
  @include border-radius(50%)

// vidro laterais  
%commons-vidro-lateral
  content: ''
  display: block
  border-bottom: 10px solid $color-glasses
  border-left: 30px solid transparent
  border-right: 40px solid transparent
  height: 10px
  width: 130px
  position: absolute
  right: 52px

// luzes de ré  
%commons-luz-de-re
  content:  ''
  width: 23px
  height: 12px
  background-color: #D92626
  position: absolute    
  bottom: -62px   

// --------------------------------------- |
// Linha de carros estacionados -----------|  
.car-line
  + .car-line
    margin-top: 40px

// --------------------------------------- |
// Espaço - vaga para estacionar ----------|  
.vacancy
  width: $width-car
  height: $height-car
  @include inline-block
  font-size: 31px
  text-align: center
  line-height: 1.5
  color: #333  
  @include box-sizing(border-box)
  padding: 10px
  &:before
    content: 'You are going to park here!'
  &:hover:before
    content: "Click the button bellow to start."
  + .car
    margin-left: $margin-left-car

// --------------------------------------- |
// Carro ----------------------------------|  
// --------------------------------------- |
.car
  width: $width-car
  height: $height-car
  background: $color-car
  position: relative    
  @include inline-block
  @include border-top-right-radius(40px 50%)
  @include border-bottom-right-radius(40px 50%)    
  @include border-bottom-left-radius(20px 30px)
  @include border-top-left-radius(20px 30px) 

  &:after   
    @extend %commons-retrovisor
    top: -12px
    @include border-radius(3px 100% 0 0)
  &:before
    @extend %commons-retrovisor
    bottom: -12px
    @include border-radius(0 0 100% 3px) 
  // Parte frontal do carro
  // Vidro frontal
  .car-front
    border-bottom: 40px solid $color-glasses
    border-left: 8px solid transparent
    border-right: 8px solid transparent
    top: 42px
    height: 0
    width: 70px
    right: 30px
    position: absolute
    @include rotate(-90deg)
    @include box-shadow(0px 3px 0 #fff)
    // Faróis
    // farol esquerdo
    &:after
      @extend %commons-farol
      @include rotate(22deg)
      left: -5px
    // farol direito
    &:before     
      @extend %commons-farol
      @include rotate(-22deg)
      right: -5px      
  // Outras cores para o carro
  &.car-blue
    background-color: $color-car-blue
  &.car-red
    background-color: $color-car-red
  &.car-silver
    background-color: $color-car-silver      

  // Espaçamento entre carros    
  + .car, 
  + .vacancy
    margin-left: $margin-left-car
  
  // Meio do carro
  // Vidros laterais 
  .car-middle
    // vidro lateral direito
    &:before
      @extend %commons-vidro-lateral
      bottom: 8px
    // vidro lateral esquerdo
    &:after
      @extend %commons-vidro-lateral
      top: 8px
      @include scale(1, -1)
  // Parte traseira do carro    
  .car-back
    content: ''
    border-bottom: 35px solid $color-glasses
    border-left: 20px solid transparent
    border-right: 20px solid transparent
    height: 0
    top: 44px
    width: 60px  
    left: -5px
    @include rotate(90deg)  
    position: absolute
    // Luzes de ré
    // luz de ré esquerda
    &:before
      @extend %commons-luz-de-re
      left: -30px        
      @include border-bottom-left-radius(40px 22px)     
    &:after  
      // luz de ré direita
      @extend %commons-luz-de-re
      right: -30px  
      @include border-bottom-right-radius(40px 22px)   

// Animação --------------------------|
// Keyframes e passos da animação ----|
// -----------------------------------|


// PASSO 1 ---------------------------|
@include keyframes(animacao-passo1)
  from
    left: 0
  to
    left: $margin-left-passo1 + 10px        

.passo1:checked + .passo2:not(:checked)
  ~ .car
    @include animation(animacao-passo1 3s ease-in-out)
    
.passo1:checked + .passo2 
  ~ .car
    left: $margin-left-passo1 + 10px

// PASSO 2 ----------------------------|
@include keyframes(animacao-passo2)
  from
    @include rotate(0)    
    left: $margin-left-passo1 + 10px        
  to 
    @include transform-origin(top, left)    
    @include rotate(.1turn)
    left: $margin-left-passo1 - 10px        

.passo1:checked + .passo2:checked + .passo3:not(:checked)
  ~ .car
    @include animation(animacao-passo2 3s)

.passo1:checked + .passo2:checked + .passo3
  ~ .car            
    @include transform-origin(top, left)        
    @include rotate(.1turn)
    left: $margin-left-passo1 - 10px

// PASSO 3 -----------------------------|
@include keyframes(animacao-passo3)
  from
    left: $margin-left-passo1 - 10px        
    top: 0
  to
    left: 470px
    top: -183px        
      
.passo1:checked + .passo2:checked + .passo3:checked
  ~ .car
    @include animation(animacao-passo3 3s ease-out)
    left: 470px
    top: -183px        
    
// PASSO 4
@include keyframes(animacao-passo4)
  from
    left: 470px
    top: -183px          
    @include rotate(.1turn)  
  to
    left: 345px
    top: -183px
    @include rotate(0deg)

.passo2:checked + .passo3:checked
  + .passo4:checked ~ .car
    @include animation(animacao-passo4 3s)
    left: 345px
    top: -183px
    @include rotate(0deg)
               
// STEPS BREADCRUMBS
// I get this from this pen: 
// https://codepen.io/arkev/pen/DzCKF from the user @arkev
.breadcrumbs
  @include inline-block
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.35)
  overflow: hidden
  border-radius: 5px
  counter-reset: flag
  position: absolute
  bottom: 25px
  left: calc(50% - 200px)
  color: #34495e
  > label
    text-decoration: none
    outline: none
    display: block
    float: left
    font-size: 12px
    line-height: 36px
    padding: 0 10px 0 60px
    position: relative
    cursor: pointer   
    &:first-child
      padding-left: 46px
      border-radius: 5px 0 0 5px
      &:before
        left: 14px
    &:last-child
      border-radius: 0 5px 5px 0
      padding-right: 20px
    &:after
      content: ''
      position: absolute
      top: 0
      right: -18px
      width: 36px
      height: 36px
      transform: scale(0.707) rotate(45deg)
      z-index: 1
      box-shadow: 2px -2px 0 2px hsl(0, 8%, 90%)
      border-radius: 0 5px 0 50px
    &:last-child:after
      content: none
    &:before
      content: counter(flag)
      counter-increment: flag
      border-radius: 100%
      width: 20px
      height: 20px
      line-height: 20px
      margin: 8px 0
      position: absolute
      top: 0
      left: 30px
      background: #444
      font-weight: bold
      text-align: center
      color: $color-glasses
  &.breadcrumbs-flat
    > label
      background: white
      color: black
      transition: all 0.5s
      &:after
        background: white
        color: black
        transition: all 0.5s
      &:before
        background: white
        box-shadow: 0 0 0 1px #ccc
      &:hover, 
      &:hover:after
        background-color: $color-glasses
        color: #fff

// CONGRATULATIONS STYLE
.congrats
  @include opacity(0)
  bottom: 140px
  position: absolute 
  visibility: hidden
  width: 100%
  color: #34495e
  .congrats-title,
  .congrats-subtitle,
  .congrats-text
    margin: 0
    line-height: 1.5
    text-align: center
  .congrats-title
    font-size: 42px
  .congrats-subtitle
    font-size: 22px
  .congrats-link
    color: $color-car-blue
    text-decoration: none
      
@include keyframes(animacao-check-step)      
  0%, 80%
    pointer-events: none
    @include opacity(.2)    
  100%
    pointer-events: all
    @include opacity(1)

@include keyframes(show-congrats)    
  0%, 50%
    @include opacity(0)
  100%
    @include opacity(100)
      
%commons-checkable-step
  pointer-events: all
  @include opacity(1)  

%commons-checked-step
  background-color: $color-glasses
  color: #fff

%commons-non-checkable-step  
  pointer-events: none
  @include opacity(.2)

 
.passo2-label,
.passo3-label,
.passo4-label  
  @extend %commons-non-checkable-step
      
// step 1 checked
input.passo1:checked
  @extend %commons-checked-step
  ~ .breadcrumbs
    > .passo1-label, 
    > .passo1-label:after           
      @extend %commons-checked-step
    > .passo2-label
      @include animation(animacao-check-step 3.2s)
      @extend %commons-checkable-step        
  // step 1 and 2 checked
  + input.passo2:checked    
    ~ .breadcrumbs
      > .passo2-label, 
      > .passo2-label:after           
        @extend %commons-checked-step      
      > .passo3-label
        @include animation(animacao-check-step 3.2s)
        @extend %commons-checkable-step
    // step 1, 2 and 3 checked        
    + input.passo3:checked
      ~ .breadcrumbs
        > .passo3-label, 
        > .passo3-label:after           
          @extend %commons-checked-step            
        > .passo4-label
          @include animation(animacao-check-step 3.2s)
          @extend %commons-checkable-step
      // step 1, 2, 3 and 4 checked                  
      + input.passo4:checked
        ~ .breadcrumbs
          > .passo4-label, 
          > .passo4-label:after           
            @include animation(animacao-check-step 3.2s)
            @extend %commons-checked-step                  
        ~ .congrats
          @include animation(show-congrats 4.4s)  
          visibility: visible
          @include opacity(1)
              
            
!

JS

              
                // Nothing to see here, this is pure css =D
// fork this project on github: https://github.com/teles/pure-css-parallel-park/
              
            
!
999px

Console