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 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

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.form
  .input-block(class="mandatory")
    label(for="input1") First Name
    input(type="text", id="input1", placeholder="Add first name", value="Camilla")

  .input-block(class="mandatory")
    label(for="input2") Last name
    input(type="text", id="input2", placeholder="Add last name")
    
  .input-block
    label(for="input3") Company  
    input(type="text", id="input3", placeholder="Add company")
   
  .input-block
    label(for="input4") Title    
    input(type="text", id="input4", placeholder="Add title")
        
  .input-block
    label(for="input5") E-mail     
    input(type="text", id="input5", placeholder="Add e-mail")
      
  .input-block
    label(for="input6") Phone 
    input(type="text", id="input6", placeholder="Add phone")
    
  .input-block
    select(name='material')
      option(value='') Select material
      option Material 1
      option Material 2
      option Material 3
      option Material 4  
      
  .input-block
    label(for="textarea") Message
    textarea(id="textarea", placeholder="Add message")
    
      
  .input-block   
    input(type="submit", value="submit")
  
              
            
!

CSS

              
                $green = #99B898 
$grey = #ccc

$form-element-style
  font-family helvetica
  font-size 16px
  color white
  width 300px 
  height 50px 
  padding 15px
  border 2px solid white 
  outline none
  -webkit-appearance: none; // remove box shadows on iOS

  .has-value &
    color white
    background-color $green
  
* 
  box-sizing border-box

body
  margin 0
  padding 0
  font-family helvetica


.form
  padding 30px
  background-color $green

.input-block
  position relative
  margin 15px 0  


//Overwrite yellow autofill background-color in webkit browsers
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0px 1000px $green inset;
  -webkit-text-fill-color: white;
}

input[type="text"]
  @extend $form-element-style;

input[type="submit"]
  @extend $form-element-style;

  background-color $green

select 
  @extend $form-element-style;

  line-height 20px
  padding 0 15px
  border-radius 0
  color $grey
  // TODO add arrow..  

  
textarea 
  @extend $form-element-style;
  
  height 200px

// Placeholder
::-webkit-input-placeholder
  color $grey
  .has-value &
    opacity 0 //Show label hide placeholder

::-moz-placeholder
  color $grey
  .has-value &
    opacity 0 //Show label hide placeholder

:-ms-input-placeholder
  color $grey
  .has-value &
    opacity 0 //Show label hide placeholder


label 
  position absolute
  top 15px
  left 15px
  padding 5px
  font-size 16px  
  color $grey
  text-transform uppercase 
  pointer-events none 

  opacity 0 //Hide label show placeholder

  transition all 0.25s ease
  
  .has-value &
    top -9px
    left 13px
    font-size 12px
    color white
    background-color $green 

    opacity 1 //Show label hide placeholder

  //-webkit-touch-callout none
	//user-select none


              
            
!

JS

              
                var $form = $('.form'),
    $elements = $form.find('input[type="text"],textarea, select');


$elements.each(function(index, element){
    refreshValueState(element);  
  
    $(element).focus(function() {
      $(element).parent().addClass('has-value');
    });
});

$elements.on('blur', function(e){
  var element = e.currentTarget;
  
  refreshValueState(element);
});

function refreshValueState(element) {
    var cleanedValue = $(element).val().replace(/^\s+$/,'');
  
    $(element).val(cleanedValue);
  
    if($(element).val() !== '') {
      $(element).parent().addClass('has-value');  
    }
  
    else {
      $(element).parent().removeClass('has-value');  
    } 
}
              
            
!
999px

Console