cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

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

<main>
  <figure>
    <picture>
      <source  media="(min-width: 768px)"
              srcset="//assets.petermueller.io/codepen/dailyui-001/img.png     340w,
                      //assets.petermueller.io/codepen/dailyui-001/img@2x.png  680w,
                      //assets.petermueller.io/codepen/dailyui-001/img@3x.png 1020w"
               sizes="360px" />
      <source srcset="//assets.petermueller.io/codepen/dailyui-001/img-small.png     340w,
                      //assets.petermueller.io/codepen/dailyui-001/img-small@2x.png  680w,
                      //assets.petermueller.io/codepen/dailyui-001/img-small@3x.png 1020w"
               sizes="(min-width: 320px) 290px,
                      (min-width: 480px) 435px
                      (min-width: 640px) 580px" />
      <img       src="//assets.petermueller.io/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>
            
          
!
            
              /* 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(//assets.petermueller.io/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';
  }
}
            
          
!
            
              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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console