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

              
                <div class="container">
  <div class="wrapper">
    <button id="gen">Generate</button>
    <button id="clear">Clear</button>
    <input id="randomNum">
    <button id="copy">Copy</button>
    <div id="copyCheck">
      <i class="glyphicon glyphicon-ok"></i>
      <span>Color Code Copied</span>
    </div>
  </div>
</div>
              
            
!

CSS

              
                * {box-sizing: border-box;}
body {
  position: relative;
  background: #F1A9A0;
}
.wrapper {
  margin: 200px auto 0;
  width: 420px;
}
button {
  width: 200px;
  padding: 10px 20px;
  background: #E74C3C;
  border: none;
  outline: none;
  color: #fff;
  font-size: 16px;
  font-weight: 100;
  transition: all 0.2s ease;
}
button:hover {background: #da493a;}
button:active {background: #f7654b;}
button:active, button:focus {outline: none;}
button#copy {width: 80px; height: 50px; position: relative;}
input#randomNum {
  width: 320px;
  height: 50px;
  outline: none;
  line-height: 50px;
  font-size: 14px;
  border: none;
  text-align: center;
  margin-top: 20px;
  color: #fff;
  box-shadow: inset 0px 0px 200px 10px #446CB3;
}
#copyCheck {
  position: fixed;
  top: 10%;
  right: -200px;
  display: inline-block;
  background: #353535;
  padding: 10px 20px;
  border-radius: 5px;
  color: #fff;
  box-shadow: 0px 3px 2px 0px rgba(0,0,0,0.32);
  transition: all 0.3s ease; 
}
#copyCheck i {
  border-radius: 50%;
  background: #2d8448;
  padding: 10px;
}
              
            
!

JS

              
                // Some Variables 
var genButton = document.getElementById("gen"), // Generate button
    clear  = document.getElementById("clear"),  // Clear button
    output = document.getElementById("randomNum"),  // Output space
    copy = document.getElementById("copy"),  // Copy to Clipboard Button
    copyCheck = document.getElementById("copyCheck");  // copy check
  

// Get Random Number Function && make it the background of the body xD
function getRandomNum() {
    "use strict";
    output.value = "#" + Math.floor((1e+5) + Math.random() * (9e+5)); // get random 6-digits number
  var bgClr = output.value; 
  document.body.style.backgroundColor = bgClr;  // set body bgColor to that random number
}
// Clear Random Number Function + make background of the body as default 
function clearNum() {
    "use strict";
    output.value = "";   // clear output space
  document.body.style.backgroundColor = "#F1A9A0";   // make bgColor of the body as default
}
// Copy the color code to the clipboard by clicking on "Copy" Button
function copyToClipBoard() {
  "use strict";
  document.execCommand("copy", false, output.select());
  copyCheck.style.right = "20px";
  showCheck = setTimeout(function() {
    copyCheck.style.right = "-200px";
  }, 3000);
  clearTimeout(showCheck);
}
// Adding EventListener to the buttons
genButton.addEventListener("click", getRandomNum);  // Generate Button
clear.addEventListener("click", clearNum);   // Clear Button
copy.addEventListener("click", copyToClipBoard);

//---------------- Thanks for being here --------------------- //
              
            
!
999px

Console