HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
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. ↗
@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)
// Nothing to see here, this is pure css =D
// fork this project on github: https://github.com/teles/pure-css-parallel-park/
Also see: Tab Triggers