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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                  <body onload="startTime()">
    <div class="container">
      <span id="clockArea">
        <p class="topText">Today is:</p>
        <div id="whatDate"></div>
        <p class="topText">The Time is:</p>
        <div id="clock"></div>
      </span>
    </div>
  </body>
              
            
!

CSS

              
                    body{
      margin:0;
      padding:0;
      font-size: 18px;
      background:black;
    }
    .container{
      position:relative;
      height: 700px;
    }
    #clockArea {
      position:absolute;
    }
    .topText{
      font-family: 'Orbitron', sans-serif;
      color: lightslategrey;
      font-style: italic;
      text-align: center;
      font-size: 1.5em;
    }
    #whatDate {
      font-family: 'Orbitron', sans-serif;
      font-size: 5em;
      margin:20px auto;
      color: limegreen;
      font-style: italic;
      text-align: center;
    }
    #clock {
      font-family: 'Orbitron', sans-serif;
      font-size: 8em;
      margin:20px auto;
      color: limegreen;
      font-style: italic;
      text-align: center;
      min-width: 1000px;
      margin-top: -20px;
    }
    @media screen and (max-width:1000px){
      #whatDate, #clock {
        font-size: 2em;
      }
      .container{
        height: 600px;
      }
      .topText {
        margin-bottom: inherit;
      }
      .clockArea {
        position:relative;
        top:inherit;
        left:inherit;
        transform: translate(0%,20%);
      }
      #clock{
        min-width: inherit;
        margin-top: 20px;
      }
    }
              
            
!

JS

              
                function startTime() {
    var today = new Date();
    var h = today.getHours();
    var m = today.getMinutes();
    var s = today.getSeconds();
    var ampm = h >= 12 ? 'PM' : 'AM'; // Display AM or PM
    m = checkTime(m);
    s = checkTime(s);
    //Convert to 12-hour (non-military time)
    if (h > 12) {
    h -= 12;
    } else if (h === 0) {
        h = 12;
    };
    document.getElementById('clock').innerHTML =
    " " + h + ":" + m + ":" + s + " " + ampm + " ";
    var t = setTimeout(startTime, 500);

    var todayDate = new Date();
    var dd = todayDate.getDate();
    var mm = todayDate.getMonth()+1; //January is 0!
    var yyyy = todayDate.getFullYear();
    if(dd<10) {
        dd = '0' + dd
    }
    if(mm<10) {
        mm = '0' + mm
    };
    document.getElementById('whatDate').innerHTML = " " + mm + '/' + dd + '/' + yyyy + " ";
}

function checkTime(i) {
    if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
    return i;
}

// To move around as a screensaver
function moveDiv() {
var $span = $("#clockArea");

$span.fadeOut(1000, function() {
    var maxLeft = $(window).width() - $span.width();
    var maxTop = $(window).height() - $span.height();
    var leftPos = Math.floor(Math.random() * (maxLeft + 1))
    var topPos = Math.floor(Math.random() * (maxTop + 1))

    $span.css({ left: leftPos, top: topPos }).fadeIn(1000);
});
};

moveDiv();
setInterval(moveDiv, 7000);

              
            
!
999px

Console