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

              
                <link href='https://fonts.googleapis.com/css?family=Montserrat:700' rel='stylesheet' type='text/css'>

<main>
  <figure>
    <picture>
      <source  media="(min-width: 768px)"
              srcset="//my-assets.netlify.com/codepen/dailyui-001/img.png     340w,
                      //my-assets.netlify.com/codepen/dailyui-001/img@2x.png  680w,
                      //my-assets.netlify.com/codepen/dailyui-001/img@3x.png 1020w"
               sizes="360px" />
      <source srcset="//my-assets.netlify.com/codepen/dailyui-001/img-small.png     340w,
                      //my-assets.netlify.com/codepen/dailyui-001/img-small@2x.png  680w,
                      //my-assets.netlify.com/codepen/dailyui-001/img-small@3x.png 1020w"
               sizes="(min-width: 320px) 290px,
                      (min-width: 480px) 435px
                      (min-width: 640px) 580px" />
      <img       src="//my-assets.netlify.com/codepen/dailyui-001/img.png"
                 alt="Citymap illustration" />
    </picture>
  </figure>
  <div class="headline">
    <h2 class="text-headline">Vino Blanco</h2>
    <h3 class="text-subheadline">The Restaurant Newsletter</h2>
  </div>
  <form>
    <span>
      <label for="username" class="text-small-uppercase">Username</label>
      <input class="text-body" id="username" name="username" type="text" required>
    </span>
    <span>
      <label for="email" class="text-small-uppercase">Email</label>
      <input class="text-body" id="email" name="email" type="email" required>
    </span>
    <span>
      <label for="city" class="text-small-uppercase">City</label>
      <input class="text-body" id="city" name="city" type="text" required>
    </span>
    <input class="text-small-uppercase" id="submit" type="submit" value="Subscribe now">
  </form>
</main>
              
            
!

CSS

              
                /* Structure */

img {
  height: auto;
  width: 100%;
}

input[type=submit] {
  background: #fff;
  height: 2.75rem;
  margin: 1em auto auto;
}

@media (min-width: 768px) {
  input[type=submit] {
    background: #fff;
    bottom: 2.75rem;
    left: 2.55rem;
    height: 2.75rem;
    padding: 0 3rem;
    position: absolute;
  }
}

input[type=email],
input[type=text] {
  height: 1.5rem;
  margin: 0 0 1.15rem;
  width: 100%;
}

figure {
  overflow: hidden;
  position: relative;
  width: 100%;
}

@media (min-width: 768px) {
  figure {
    float: left;
    height: 100%;
    position: relative;
    width: 50%;
  }
}

form {
  overflow: hidden;
  padding: 10%;
  position: relative;
  width: 80%;
}

@media (min-width: 768px) {
  form {
    float: left;
    height: 78%;
    padding: 6%;
    width: 38%;
  }
}

main {
  margin: 30px auto auto;
  overflow: hidden;
  position: relative;
  width: 90%;
}

@media (min-width: 768px) {
  main {
    height: 21.25rem;
    left: 50%;
    margin: auto;
    position: absolute;
    transform: translate(-50%, -50%);
    top: 50%;
    width: 42.5rem;
  }
}

.headline {
  position: absolute;
  top: 8vw;
  width: 100%;
}

@media (min-width: 768px) {
  .headline {
    position: absolute;
    top: 3.4rem;
    width: 50%;
  }
}

/* Skin */

* {
  margin: 0;
  padding: 0;
}

body {
  background: #74bdb7;
  font: 700 16px 'Montserrat', sans-serif;
}

input[type=email],
input[type=text] {
  background: none;
  border: none;
  border-bottom: 2px solid #74bdb7;
  box-sizing: border-box;
  outline: none;
}

input[type=email]:required,
input[type=text]:required {
  box-shadow: none;
  outline: none;
}

input[type=submit] {
  background: #f37b56;
  border: none;
  color: #fff;
  padding: 0 2rem;
}

input[type=submit]:hover,
input[type=submit]:focus {
  background: #f79577;
  cursor: pointer;
  outline: none;
}

.inputs--filled label {
  transform: translate(0, 0);
}

.inputs--invalid input {
  animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
  background: url(//my-assets.netlify.com/codepen/dailyui-001/ico-invalid.svg) center right no-repeat;
  border-bottom: 2px solid #f37b56;
  box-shadow: none;
  color: #f37b56;
  transform: translate3d(0, 0, 0);
}

@keyframes shake {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }

  33% {
    transform: translate3d(-6px, 0, 0);
  }

  66% {
    transform: translate3d(6px, 0, 0);
  }
}

.inputs--invalid label {
  color: #f37b56;
}

label {
  display: inline-block;
  transform: translate(0, 1.25rem);
  transition: 0.15s;
}

main {
  background: #f9f6ed;
  border-radius: 0.25rem;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.1);
}

.text-headline {
  color: #74bdb7;
  letter-spacing: 0.4rem;
  font: 700 1.4em 'Montserrat';
  text-align: center;
  text-transform: uppercase;
}

@media (min-width: 768px) {
  .text-headline {
    font: 700 1.625rem 'Montserrat';
  }
}

.text-body {
  color: #354c58;
  font: 700 16px 'Montserrat', sans-serif;
}

.text-small-uppercase {
  color: #74bdb7;
  font: 700 .75rem 'Montserrat';
  letter-spacing: .08rem;
  text-transform: uppercase;
}

.text-subheadline {
  color: #f37b56;
  left: -.17rem;
  letter-spacing: .143rem;
  font: 700 0.652rem 'Montserrat';
  margin-bottom: 1.5rem;
  position: relative;
  text-align: center;
  text-transform: uppercase;
}

@media (min-width: 768px) {
  .text-subheadline {
    font: 700 0.75rem 'Montserrat';
  }
}
              
            
!

JS

              
                var inputs = document.querySelectorAll( 'input[type=text], input[type=email]' );
for (i = 0; i < inputs.length; i ++) {
  var inputEl = inputs[i];
  if( inputEl.value.trim() !== '' ) {
  	inputEl.parentNode.classList.add( 'input--filled' );
  }
  inputEl.addEventListener( 'focus', onFocus );
  inputEl.addEventListener( 'blur', onBlur );
}

function onFocus( ev ) {
  ev.target.parentNode.classList.add( 'inputs--filled' );
}

function onBlur( ev ) {
  if ( ev.target.value.trim() === '' ) {
  	ev.target.parentNode.classList.remove( 'inputs--filled' );
  } else if ( ev.target.checkValidity() == false ) {
    ev.target.parentNode.classList.add( 'inputs--invalid' );
    ev.target.addEventListener( 'input', liveValidation );
  } else if ( ev.target.checkValidity() == true ) {
    ev.target.parentNode.classList.remove( 'inputs--invalid' );
    ev.target.addEventListener( 'input', liveValidation );
  }
}

function liveValidation( ev ) {
  if ( ev.target.checkValidity() == false ) {
    ev.target.parentNode.classList.add( 'inputs--invalid' );
  } else {
    ev.target.parentNode.classList.remove( 'inputs--invalid' );
  }
}

var submitBtn = document.querySelector( 'input[type=submit]' );
submitBtn.addEventListener( 'click', onSubmit );

function onSubmit( ev ) {
  var inputsWrappers = ev.target.parentNode.querySelectorAll( 'span' );
  for (i = 0; i < inputsWrappers.length; i ++) {
    input = inputsWrappers[i].querySelector( 'input[type=text], input[type=email]' );
    if ( input.checkValidity() == false ) {
      inputsWrappers[i].classList.add( 'inputs--invalid' );
    } else if ( input.checkValidity() == true ) {
      inputsWrappers[i].classList.remove( 'inputs--invalid' );
    }
  }
}
              
            
!
999px

Console