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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <form>
   <h3>CONTACTEZ NOUS !</h3>
   <div>
      <input type="text" id="nom" placeholder="Qui êtes-vous ?"/>
   		<label for="nom">Nom</label>
   </div>
   <div>
      <input type="text" id="prenom" placeholder="Qui êtes-vous ?"/>
   		<label for="prenom">Prénom</label>
   </div>
   <div>
      <input type="text" id="mail" placeholder="Quelle est votre adresse Mail ?"/>
   		<label for="mail">Mail</label>
   </div>
   <div>
      <textarea id="msg"  placeholder="Tapez ici votre message"/></textarea>
      <label for="msg">Message</label>
   </div>
   <input class="button" type="submit" value="Envoyer" />
</form>
  
  
              
            
!

CSS

              
                /* Ressources */
html{  background:url('//vincentrocher.fr/codepen/images/backgrounds/background-desktop.jpg') center;
  background-size:cover;
  min-height:100%;
  font-family:"Quicksand","Open Sans",sans-serif;
  padding-top:50px;
}
form{
  max-width:850px;
  margin:0 auto;
  border-top:15px solid #313A3D;
  background:#FFF;
  padding:0 20px 60px;
  text-align:center;
  font-family:Raleway;
  text-align:center;
  color:#B6B6B6;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  opacity:0.95;
  box-shadow:0 0 15px -1px #141414;
}
h3{
  text-transform:uppercase;
  font-size:20px;
  line-height:60px
}
div *{box-sizing:border-box;}
div{
  width:70%;
  margin:10px auto;
  height:50px;
}
div input, textarea{
  width:100%;
  height:100%;
  opacity:0.9;
  padding-left:22%;
  background-color:#E8E9EA;
  border:0;
  outline:none;
  margin:0;
}
label{
  display:block;
  position:relative;
  top:-50px;
  width:100%;
  height:100%;
  background-color:#313A3D;
  position:relative;
  line-height:50px;
  font-size:18px;
  transition: all 0.3s ease-in-out,width 0.7s ease-in-out;
  text-transform:uppercase;
}
.ouvert label{ width:20%; }
#formContact .contactChamp:nth-child(3) label{
  transition: all 0.3s ease-in-out, width 0.7s ease-in-out; }
#formContact .contactChamp:nth-child(4) label{
  transition: all 0.3s ease-in-out, width 0.9s ease-in-out; }
#formContact .contactChamp:nth-child(5) label{
  transition: all 0.3s ease-in-out, width 1.1s ease-in-out; }
#formContact .contactChamp:nth-child(6) label{
  transition: all 0.3s ease-in-out, width 1.3s ease-in-out; }


div:hover label, div input:focus + label,div textarea:focus + label, .labelOuvert{
  width:20%;
}
div input:focus + label,div textarea:focus + label{
  background-color:rgb(116, 181, 89);
  color:#313A3D;
}
input[type=submit]{
  background-color:#313A3D;
  border:0;
  height:50px;
  padding:0 20px;
  text-transform:uppercase;
  color:rgb(116, 181, 89);
  font-size:15px;
  margin-top:35px;
}
textarea{
  resize: none;
  padding-top:18px;
  transition:all 0.3s ease-in-out;
}
textarea + label{
  top:-54px;
}
textarea:focus, .messOuvert textarea{
  height:150px;
}
textarea:focus + label,.messOuvert label{
  top:-154px;
  height:150px;
  line-height:150px;
}
.messOuvert{
  margin-bottom:100px
}



@media screen and (max-width: 1070px) {
  form{
    width:100%;
  }
  form div{
    width:90%;
  }
}
              
            
!

JS

              
                $('form').delay(1000).addClass('ouvert');


// En sortant d'un champ du Form (désélection)
$('input,textarea').blur(function () {
  if($(this).siblings('label').attr('for')=='msg'){ // Si c'est le textarea Message
    $(this).parent().css('margin-bottom','0'); // On retire la marge (qui baisse le bouton submit)
  }
  if ( $(this).val() != '' ) { // Si le champs est rempli
    $(this).siblings('label').addClass('labelOuvert'); // On laisse le label en petit
    if($(this).siblings('label').attr('for')=='msg'){ // Si c'est le champ message
      $(this).parent().addClass('messOuvert'); // Ajout de la classe pour agrandir le champ
      $(this).parent().css('margin-bottom','100px'); // On baisse le bouton
    }
  }
  else {
    $(this).siblings('label').removeClass('labelOuvert');
    if($(this).siblings('label').attr('for')=='msg'){ // Si c'est le textarea Message
      $(this).parent().removeClass('messOuvert'); // Retrait de la classe pour reduire le champ
    }
  }
});

$('textarea').focus(function () { // Au clic sur le textarea Message
  if($(this).val() == ''){ // Si le champ est vide
    $(this).parent().css('margin-bottom','100px'); // Rajout de la marge pour baisser le bouton submit
  }
});
              
            
!
999px

Console