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

              
                <body>
  <header>
    <h3 id="themes" class="light-text">Switch to light theme</h3>
    <label for="check" id="switch">
      <input id="check" class="input" type="checkbox">
      <div id="circle"></div>
    </label>
  </header>
  <div id="particles-js"></div>
  
  <div id="clock-wrapper">
    <div id="hours-group">
      <div id="hours-tens" class="digit">
        <div class="led top horizontal"></div>
        <div class="led top left vertical"></div>
        <div class="led top right vertical"></div>
        <div class="led middle horizontal"></div>
        <div class="led bottom left vertical"></div>
        <div class="led bottom right vertical"></div>
        <div class="led bottom horizontal"></div>
      </div>
      <div id="hours-units" class="digit">
        <div class="led top horizontal"></div>
        <div class="led top left vertical"></div>
        <div class="led top right vertical"></div>
        <div class="led middle horizontal"></div>
        <div class="led bottom left vertical"></div>
        <div class="led bottom right vertical"></div>
        <div class="led bottom horizontal"></div>
      </div>
    </div>

    <div class="colon">
      <div class="top-point"></div>
      <div class="bottom-point"></div>
    </div>

    <div id="minutes-group">
      <div id="minutes-tens" class="digit">
        <div class="led top horizontal"></div>
        <div class="led top left vertical"></div>
        <div class="led top right vertical"></div>
        <div class="led middle horizontal"></div>
        <div class="led bottom left vertical"></div>
        <div class="led bottom right vertical"></div>
        <div class="led bottom horizontal"></div>
      </div>
      <div id="minutes-units" class="digit">
        <div class="led top horizontal"></div>
        <div class="led top left vertical"></div>
        <div class="led top right vertical"></div>
        <div class="led middle horizontal"></div>
        <div class="led bottom left vertical"></div>
        <div class="led bottom right vertical"></div>
        <div class="led bottom horizontal"></div>
      </div>
    </div>

    <div class="colon">
      <div class="top-point"></div>
      <div class="bottom-point"></div>
    </div>

    <div id="seconds-group">
      <div id="seconds-tens" class="digit">
        <div class="led top horizontal"></div>
        <div class="led top left vertical"></div>
        <div class="led top right vertical"></div>
        <div class="led middle horizontal"></div>
        <div class="led bottom left vertical"></div>
        <div class="led bottom right vertical"></div>
        <div class="led bottom horizontal"></div>
      </div>
      <div id="seconds-units" class="digit">
        <div class="led top horizontal"></div>
        <div class="led top left vertical"></div>
        <div class="led top right vertical"></div>
        <div class="led middle horizontal"></div>
        <div class="led bottom left vertical"></div>
        <div class="led bottom right vertical"></div>
        <div class="led bottom horizontal"></div>
      </div>
    </div>
  </div>
              
            
!

CSS

              
                /**** Colors of the clock and theme ****/
:root {
  --led-color: #64ccc3;
  --dark-theme-color: #1D1F20;
  --light-theme-color: #EFEFEF;
}

/**** General reset ****/
* {
  margin: 0;
  padding: 0;
  /* box-sizing: border-box; */
}

html, body { 
  width: 100%;
  height: 100%;
  font-family: 'Quicksand', sans-serif;
}

/**** Flex components ****/
body,
header,
#clock-wrapper,
#hours-group,
#minutes-group,
#seconds-group,
.colon,
label  {
  display: flex;
  justify-content: center;
  align-items: center;
}

/**** Fonts ****/
h3 {
  font-size: 30px;
}

/**** Layout ****/
body {
  background-color:var(--dark-theme-color);
  flex-direction: column;
  position: absolute;
}

header {
  width: 100%;
  height: 80px;
  position: absolute;
  top: 0;
}

#particles-js {
  position: fixed;
  width: 100%;
  height: 100%;
  z-index: -1;
}

#clock-wrapper {
  height: calc(100vh - 80px);
  position: absolute;
  bottom: 0;
  text-align: center;
}

/**** Clock layout ****/
#hours-group,
#minutes-group,
#seconds-group {
  position: relative;
  width: 180px;
  height: 160px;
}

/**** Clock components ****/
.digit {
  position: relative;
  display: inline-block;
  width: 80px;
  height: 160px;
  margin-left: 5px;
  margin-right: 5px;
  text-align: left;
}

.colon {
  position: relative;
  flex-direction: column;
  text-align: center;
  width: 50px;
  height: 160px;
  text-align: center;
}

.led {
  position: absolute;
  opacity: 0.06;
  border-radius:5px;
  transition: opacity 0.3s;
  -webkit-transition:opacity 0.3s;
  -ms-transition: opacity 0.3s;
  -moz-transition: opacity 0.3s;
  -o-transition: opacity 0.3s; 
  box-shadow: 0 0 50px rgba(100,199,204, 0.5);
}

/**** Clock vertical and horizontal segments ****/
.vertical {
  width: 10px; 
  height: 60px;
  background-color: var(--led-color);
  border-radius:5px;
}

.horizontal {
  width: 60px; 
  height: 10px;
  background-color: var(--led-color);
  border-radius:5px;
}

/**** Top segments ****/
.top {
  top: 6px;
  left: 11px;
}

.top.left {
  top: 15px;
  left: 0;
}

.top.right {
  top: 7px;
  left: 72px;
  margin-top: 8px;
}

/**** Middle segments ****/
.middle {
  top: 74px;
  left: 11px;
}

/**** Bottom segments ****/
.bottom.left {
  top: 84px;
  left: 0;
}

.bottom.right {
  top: 84px;
  left: 72px;
}

.bottom {
  top: 143px;
  left: 11px;
}

/**** Point separators ****/
.top-point,
.bottom-point {
  background-color: var(--led-color);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin: 5px;
}

/**** DIGITS ****/
/**** Zero ****/
.zero * {
  opacity: 1;
}

.zero .middle {
  opacity: 0.06;
}

/**** One ****/
.one * {
  opacity: 0.06;
}

.one .top.right,
.one .bottom.right {
  opacity: 1;
}

/**** Two ****/
.two * {
  opacity: 1;
}

.two .top.left,
.two .bottom.right {
  opacity: 0.06;
}

/**** Three ****/
.three * {
  opacity: 1;
}

.three .top.left,
.three .bottom.left {
  opacity: 0.06;
}

/**** Four ****/
.four .top,
.four .bottom {
  opacity: 0.06;
}

.four .top.right,
.four .top.left,
.four .middle,
.four .bottom.right {
  opacity: 1;
}

/**** Five ****/
.five * {
  opacity: 1;
}

.five .top.right,
.five .bottom.left {
  opacity: 0.06;
}

/**** Six ****/
.six * {
  opacity: 1;
}

.six .top.right {
  opacity: 0.06;
}

/**** Seven ****/
.seven * {
  opacity: 0.06;
}

.seven .top,
.seven .bottom.right {
  opacity: 1;
}

.seven .top.left {
  opacity: 0.06;
}

/**** Eight ****/
.eight * {
  opacity: 1;
}

/**** Nine ****/
.nine * {
  opacity: 1;
}

.nine .bottom.left {
  opacity: 0.06;
}
/**** END DIGITS ****/

/**** Themes switcher ****/
label {
  margin: 20px;
}

#switch {
  width: 100px;
  background: rgba(128, 128, 128, 0.2);
  position: relative;
  height: 48px;
  border-radius: 25px;
  cursor: pointer;
  transition: all .25s ease;
}

.input {
  width: 100%;
  position: absolute;
  left: 0px;
  top: 0px;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#switch:hover {
  background: rgba(99, 107, 144,.25);
}

#circle {
  position: absolute;
  left: 0px;
  top: 0px;
  margin: 5px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgb(99, 134, 144);
  transition: all .25s ease;
  box-shadow: 0px 10px 20px 0px rgba(99, 134, 144,.35);
  opacity: .4;
}

/**** Switcher active ****/
.input:checked ~ #circle {
  left: 52px;
  opacity: 1;
}

/**** Light background theme and light color ****/
.light {
  background-color: var(--light-theme-color);
  transition: ease 0.5s;
}

.light-text {
  color: var(--light-theme-color);
  transition: ease 0.5s;
}

/**** Dark background theme and light color ****/
.dark {
  background-color: var(--dark-theme-color);
  transition: ease 0.5s;
}

.dark-text {
  color: #638693;
  transition: ease 0.5s;
}

/**** Responsive ****/
@media only screen and (max-width: 500px) {
  h3 {
    font-size: 20px;
  }

  #clock-wrapper {
    flex-direction: column;
    justify-content: flex-end;
    transform: scale(0.9);
    transform-origin: center;
  }

  .colon {
    width: 100%;
    height: 50px;
    flex-direction: row;
  }

  label {
    margin: 10px;
  }
  .top-point,
  .bottom-point {
    width: 10px;
    height: 10px;
  }
}

noscript {
  color: white;
  text-align: center;
}

@media only screen and (min-width: 500px) and (max-width: 800px) {
  h3 {
    font-size: 20px;
  }
  
  #clock-wrapper {
    transform: scale(0.8);
    transform-origin: center;
  }
}
              
            
!

JS

              
                const checkInput = document.getElementById('check');
checkInput.checked = false;
const textElement = document.getElementById('themes');
checkInput.addEventListener('click', handleThemeChange);

function startClock() {
  setInterval(() => {
    // Get time data
    let currentTime = new Date();
    let hours = currentTime.getHours();
    let minutes = currentTime.getMinutes();
    let seconds = currentTime.getSeconds();

    let hoursToStr;
    let minutesToStr;
    let secondsToStr;

    // Handle 0-9 digits to be with the leading zero
    if (hours < 10) {
      hoursToStr = `0${hours}`;
    } else {
      hoursToStr = hours.toString();
    };

    if (minutes < 10) {
      minutesToStr = `0${minutes}`;
    } else {
      minutesToStr = minutes.toString();
    };

    if (seconds < 10) {
      secondsToStr = `0${seconds}`;
    } else {
      secondsToStr = seconds.toString();
    };

    let currentTimeString = hoursToStr + minutesToStr + secondsToStr;
    let currentTimeArray = currentTimeString.split("");
    let numbersArray = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];

    // Get elements from the page
    let hoursTens = document.getElementById("hours-tens");
    let hoursUnits = document.getElementById("hours-units");
    let minutesTens = document.getElementById("minutes-tens");
    let minutesUnits = document.getElementById("minutes-units");
    let secondsTens = document.getElementById("seconds-tens");
    let secondsUnits = document.getElementById("seconds-units");

    // Add class name that will handle displaying a digit
    hoursTens.className = "digit" + " " + numbersArray[currentTimeArray[0]];
    hoursUnits.className = "digit" + " " + numbersArray[currentTimeArray[1]];
    minutesTens.className = "digit" + " " + numbersArray[currentTimeArray[2]];
    minutesUnits.className = "digit" + " " + numbersArray[currentTimeArray[3]];
    secondsTens.className = "digit" + " " + numbersArray[currentTimeArray[4]];
    secondsUnits.className = "digit" + " " + numbersArray[currentTimeArray[5]];
  }, 1000);
};

function handleThemeChange() {
  if (checkInput.checked === true) {
    document.body.className = 'light';
    textElement.className = 'dark-text';
    textElement.textContent = 'Switch to dark theme';
    loadParticles('#638693', 0.7);
  } else {
    document.body.className = 'dark';
    textElement.className = 'light-text';
    textElement.textContent = 'Switch to light theme';
    loadParticles('#EFEFEF', 0.4);
  };
};

function loadParticles(color, opacity) {
  particlesJS("particles-js", {
    "particles": {
      "number": {
        "value": 355,
        "density": {
          "enable": true,
          "value_area": 789
        }
      },
      "color": {
        "value": `${color}`,
      },
      "shape": {
        "type": "circle",
      },
      "opacity": {
        "value": opacity,
        "random": false,
        "anim": {
          "enable": true,
          "speed": 1,
          "opacity_min": 0,
          "sync": false
        }
      },
      "size": {
        "value": 2.5,
        "random": true,
        "anim": {
          "enable": true,
          "speed": 2,
          "size_min": 0,
          "sync": false
        }
      },
      "line_linked": {
        "enable": false,
      },
      "move": {
        "enable": true,
        "speed": 0.2,
        "direction": "none",
        "random": true,
        "straight": false,
        "out_mode": "out",
        "bounce": false,
        "attract": {
          "enable": false,
        }
      }
    },
    "interactivity": {
      "detect_on": "canvas",
      "events": {
        "onhover": {
          "enable": true,
          "mode": "bubble"
        },
        "onclick": {
          "enable": false,
        },
        "resize": true
      },
    },
    "retina_detect": true
  });
};

loadParticles('#EFEFEF', 0.4);
startClock();
              
            
!
999px

Console