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

              
                <h1>Gracefully Degrading Float Label Demo</h1>
<p>Inspired by <a href="http://mattdsmith.com/float-label-pattern/" target="_blank">"Float Label Pattern Standard"</a> from Matt D. Smith</p>

<p><b>UPDATE</b> To improve the animation a bit, I switched to CSS keyframes now. In the first version, the labels would fly over the text input. The placeholder now first fades out and then appears again above the input field and finally docks to the final position. This might seem a minor change but this approach seems to be a lot more versatile while still very clean.</p>

<p>After <a href="https://cdpn.io/dxLtG" target="_blank">experimenting with pure CSS float labels</a> and realizing that this is currently not feasible in a semantically clean way; I decided to built another version which degrades gracefully to older browser versions and non-js users.</p>

<p>The main point is: We don't want to have labels placed next to the input fields but we have to deal with clients that either do not support input::placeholder attributes or cannot change layout dynamically because Javascript is off/broken/old/whatever.</p>

<p>Solution: The floated label is the new standard layout! On Javascript enabled clients, the label will be moved to the normal placeholder position on load. After user input, it is pushed to the top left corner and stays there, exactly as @mds has designed it to be. On Non-Javascript clients, the label will just remain in the top left corner from the beginning, eventually changing color on focus/blur.</p>

<p>This brings you placeholder support for older browsers unobtrusively and for free.</p>
<h2>Try</h2>
<p data-height="268" data-theme-id="0" data-slug-hash="nrcak" data-user="psorowka" data-default-tab="result" class='codepen'>See the Pen <a href='https://codepen.io/psorowka/pen/nrcak'>GD Float Labels Minimal</a> by Peter Sorowka (<a href='https://codepen.io/psorowka'>@psorowka</a>) on <a href='https://codepen.io'>CodePen</a></p>
<script async src="//codepen.io/assets/embed/ei.js"></script>


<i>tweet me @psorowka</i>
  
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Karla);

body {
    font-family: Karla;
    width: 40em;
    line-height: 1.3em;
}

              
            
!

JS

              
                


              
            
!
999px

Console