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.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <link href="//static.qgov.net.au/assets/v2/style/layout-medium.css" media="only all and (min-width: 640px) and (max-width: 980px)" rel="stylesheet" type="text/css" />
	<link href="//static.qgov.net.au/assets/v2/style/layout-large.css" media="only all and (min-width: 980px)" rel="stylesheet" type="text/css" />

<section><div class="global-alert">
  <div class="header">
    <h2><a href="/emergency/">Emergency alert</a></h2>
    <time datetime="2014-10-20T12:30:00+10:00">about 3 minutes ago</time>
  </div>

  <div class="summary">
    <p>
      <a href="http://www.qldalert.com">Tropical Cyclone Nathan</a>
    </p>
  </div>
</div></section>

<section id="code">
  <h2>Grab the HTML!</h2>
<pre><code id="output" class="html"></code></pre>
</section>

<section id="form">
<h2>Edit global alert</h2>
<form class="form">
  <ol class="questions">
    <li>
      <label for="h2">
        <span class="label">H2 heading</span>
        <abbr title="(required)">*</abbr>
      </label>
      <input type="text" id="h2" size="40" required list="h2-datalist" value="Weather alert">
    </li>
    <li>
      <label for="summary">
        <span class="label">P summary</span>
        <abbr title="(required)">*</abbr>
      </label>
      <input type="text" id="summary" size="40" required placeholder="Tropical Cyclone Nathan" value="Tropical Cyclone">
    </li>
    <li class="atomic group">
      <fieldset>
        <legend>
          <span class="label">Timestamp</span>
          <abbr title="(required)">*</abbr>
        </legend>
        <ol class="questions compact">
          <li>
            <label for="date">
              <span class="label">Date</span>
            </label>
            <input type="date" id="date" required>
          </li>
          <li>
            <label for="time">
              <span class="label">Time (in Queensland)</span>
            </label>
            <input type="time" id="time" required>
          </li>
        </ol>
      </fieldset>
    </li>
    
    <li>
      <label for="url">
        <span class="label">Web address</span>
        <abbr title="(required)">*</abbr>
      </label>
      <input type="text" id="url" value="http://www.qldalert.com/" required size="40">
    </li>
  </ol> 
  
</form>

<datalist id="h2-datalist">
  <option>Weather alert</option>
  <option>Emergency alert</option>
</datalist>
</section>
              
            
!

CSS

              
                body {
  padding: 1em 5em;
  background: #fafafa; 
}

#code {
  float: right;
  width: 50%;
}
#form {
  float: left;
  width: 50%;
}
              
            
!

JS

              
                var NOW = new Date();
var date = $( '#date' );
var time = $( '#time' );

// initial values
date[ 0 ].value = NOW.toISOString().replace( /T.*$/, '' );
time[ 0 ].value = NOW.toTimeString().replace( /:[^:]*$/, '' );


// update HTML
function updateGlobalAlert() {
  $( 'h2 > a', '.global-alert' ).text( $( '#h2' ).val() );
  $( 'a', '.global-alert > .summary' ).text( $( '#summary' ).val() );
  $( 'a', '.global-alert' ).attr( 'href', $( '#url' ).val() );
  var timestamp = new Date( date.val() + 'T' + time.val() + ':00+10:00' );
  
  $( 'time', '.global-alert' ).text( moment( timestamp ).format( 'D MMMM YYYY' ));
  $( 'time', '.global-alert' ).attr( 'datetime', timestamp.toISOString() );

	$( '#output' ).text( $( '.global-alert' ).parent().html() );

$( 'pre code' ).each(function( i, block ) {
    hljs.highlightBlock( block );
  });
}

// onload
updateGlobalAlert();

// onchange
$( 'input' ).on( 'change input', updateGlobalAlert );

              
            
!
999px

Console