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

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

              
                <h1>Select row when &lt;input&gt; has focus:</h1>
<div class="row clearfix">
  <label>Name:<br>
   <input type="text">
  </label>
  <label>E-mail:<br>
    <input type="email">
  </label>
</div>	
<div class="row clearfix">
  <label>Password:<br>
   <input type="password">
  </label>
  <label>Confirm your Password:<br>
    <input type="password">
  </label>
</div>
<hr>
<p>Improve usability by highlighting the row the user needs to focus on.</p>
<p>Inspired by Wufoo's plans forms: <a href="https://secure.wufoo.com/signup/1">https://secure.wufoo.com/signup/1</a></p>
 <p>Created by <a href="http://ricardozea.me/">Ricardo Zea</a></p>
              
            
!

CSS

              
                @import "compass/css3";

//Styling stuff, not needed for the demo
//Sass/Compass stuff
@import "compass/css3/images";
$MyBlack: #272822;
$r: #c03;
$g: #429032;
$b: #2963bd;
$y: #c90;

a,
a:visited {
    color: $b;
}
a:hover {
    color: $y;
    text-decoration: none;
}

* {
    @include box-sizing(border-box);
}
html {
    height: 100%;
}
body {
    padding: 0 100px;
    @include background(radial-gradient(lighten($MyBlack, 5%), $MyBlack 80%));
    font-family: "Trebuchet MS";
}
label {
    width: 100%;
    margin-bottom: 10px;
    color: white;
    text-shadow: 0 1px 0 rgba(black, 0.5);
}
input {
    margin-top: 5px;
    padding: 10px;
    width: 100%;
    border-radius: 1px;
    border: 1px solid transparent;
    font: normal 18px "Trebuchet MS";
    box-shadow: inset 0 2px 2px rgba(black, 0.4);
    &:hover {
        background: lighten($y, 40%);
    }
    &:focus {
        background: lighten($y, 40%);
        border: 1px solid black;
    }
}
hr {
    margin: 30px auto;
    border: none;
    border-top: #666 1px dotted;
    text-align: center;
    color: white;
}
h1 {
    text-align: center;
    color: white;
}
p {
    color: white;
}

//Clearfix - http://davidwalsh.name/css-clear-fix
.clearfix:before,
.clearfix:after {
    display: block;
    content: "";
    height: 0;
    overflow: hidden;
}
.clearfix:after {
    clear: both;
}

//======================================
//Demo stuff - Edit below this line

.row {
    width: 500px;
    margin: 0 auto 30px;
    padding: 30px;
    background: rgba(black, 0.2);
    border-radius: 2px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(black, 0.5), inset 0 0 0 1px rgba(white, 0.2),
        inset 0 0 0 5px rgba(white, 0.06);
    label {
        float: left;
        margin-right: 3%;
    }
    label:last-of-type {
        margin: 0;
    }
}

.focus {
    background: darken($b, 10%);
    color: #fff;
}

              
            
!

JS

              
                //Inspired by Wufoo's plans' forms: https://secure.wufoo.com/signup/1/

//Improve usability by highlighting the row the user needs to focus on:
//This script only works with jQuery 1.9.x
$("input").on("focus blur", function(){
    $(this).closest(".row").toggleClass("focus");
});

//http://stackoverflow.com/questions/14613486/jquery-optimize-code-learning-case

//Another optimized script. No need to wrap this inside $(function(){...});
/*
var onRowFocus = function(){
    $('.row').removeClass('focus');
    $(this).closest('.row').addClass('focus');
};

$('.row').on('focus', 'input', onRowFocus);
*/


//For older versions of jQuery (ie. 1.6.2)
/*$(function() {
    $('input')
        .focus(function() {
            $(this).closest('.row').addClass('focus');
        })
        .blur(function() {
            $(this).closest('.row').removeClass('focus');
        });
});*/
              
            
!
999px

Console