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 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

              
                <head>
  <title>Aaron's Game Dice</title>
  <meta charset="utf-8"/>
</head>

<body>
  <div id="headerDiv">
    <h1 id="pageHeader">Aaron's Game Dice Set</h1>
    <p id="headerIntro">A Dice Set for Dungeons & Dragons</p>
    <div class="container">
      <div class="center">
        <button class="removeButton" value="delete" onclick="deleteValues()">Delete Values</button>
      </div>
    </div>
  </div>
  
  <div id="bodyDiv">
  
    <div id="div1" class="sectionDiv">
      <!--20 SIDED DICE-->
      <section class="pageSection" id="twentySideDice">
        <h3 class="sectionHeader">20-Sided Dice</h3>
        <button class="diceButton" id="twentySidedDiceButton" value="roll" onclick="twentySideDiceRoll()">Roll!</button>
        <div class="classResultDiv" id="twentySideDiceResult"></div>
      </section>
    </div>

      <!--12 SIDED DICE-->
    <div id="div2" class="sectionDiv">
      <section class="pageSection" id="twelveSideDice">
        <h3 class="sectionHeader">12-Sided Dice</h3>
        <button class="diceButton" id="twelveSidedDiceButton" value="roll" onclick="twelveSideDiceRoll()">Roll!</button>
        <div class="classResultDiv" id="twelveSideDiceResult"></div>
      </section>
    </div>

      <!--10 SIDED DICE-->
    <div id="div3" class="sectionDiv">
      <section class="pageSection" id="tenSideDice">
        <h3 class="sectionHeader">10-Sided Dice</h3>
        <button class="diceButton" id="tenSidedDiceButton" value="roll" onclick="tenSideDiceRoll()">Roll!</button>
        <div class="classResultDiv" id="tenSideDiceResult"></div>
      </section>
    </div>

    <div id="div4" class="sectionDiv">
      <!--8 SIDED DICE-->
      <section class="pageSection" id="eightSideDice">
        <h3 class="sectionHeader">8-Sided Dice</h3>
        <button class="diceButton" id="eightSidedDiceButton" value="roll" onclick="eightSideDiceRoll()">Roll!</button>
        <div class="classResultDiv" id="eightSideDiceResult"></div>
      </section>
    </div>

    <div id="div5" class="sectionDiv">
      <!--6 SIDED DICE-->
      <section class="pageSection" id="sixSideDice">
        <h3 class="sectionHeader">6-Sided Dice</h3>
        <button class="diceButton" id="sixSidedDiceButton" value="roll" onclick="sixSideDiceRoll()">Roll!</button>
        <div class="classResultDiv" id="sixSideDiceResult"></div>
      </section>
    </div>

    <div id="div6" class="sectionDiv">
      <!--4 SIDED DICE-->
      <section class="pageSection" id="fourSideDice">
        <h3 class="sectionHeader">4-Sided Dice</h3>
        <button class="diceButton" id="fourSidedDiceButton" value="roll" onclick="fourSideDiceRoll()">Roll!</button>
        <div class="classResultDiv" id="fourSideDiceResult"></div>
      </section>
    </div>
  </div>
</body>

<footer>
  <div id="footerDiv">
    <p class="footerText">Version 1.1</p>
    <p class="footerText">Created by Aaron McCollum</p>
    <p class="footerText">Twitter @mccollumaarons</p>
  </div>
</footer>
              
            
!

CSS

              
                /* DESKTOP SETTINGS */

/* Page Header Settings */
#pageHeader {
  font-family: arial;
  font-size: 45px;
  text-align: center;
}

.container {
  position: relative;
}

.center {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}

#headerIntro {
  font-family: arial;
  font-size: 20px;
  text-align: center;
  padding-bottom: 30px;
}

/* Page Body Settings */
#bodyDiv {
  display: flex;
  flex-flow: row wrap;
  justify-content: center;
}

.sectionDiv {
  padding: 20px;
}

.sectionHeader {
  font-family: arial;
  font-size: 25px;
}

.diceButton {
  height: 30px;
  width: 100px;
  font-size: 18px;
  font-weight: bold;
}

.removeButton {
  height: 30px;
  width: 150px;
  font-size: 18px;
  font-weight: bold;
}

#twentySideDiceResult {
  font-size: 25px;
  font-family: arial;
  background-color: #acc4f1;
}

#twelveSideDiceResult {
  font-size: 25px;
  font-family: arial;
  background-color: #acc4f1;
}

#tenSideDiceResult {
  font-size: 25px;
  font-family: arial;
  background-color: #acc4f1;
}

#eightSideDiceResult {
  font-size: 25px;
  font-family: arial;
  background-color: #acc4f1;
}

#sixSideDiceResult {
  font-size: 25px;
  font-family: arial;
  background-color: #acc4f1;
}

#fourSideDiceResult {
  font-size: 25px;
  font-family: arial;
  background-color: #acc4f1;
}

/* FOOTER SETTINGS */
.footerText {
  text-align: center;
}

#footerDiv {
  padding-top: 80px;
}
              
            
!

JS

              
                //REMOVING VALUES FROM PAGE
function deleteValues() {
  var publicResult = document.querySelectorAll(".classResultDiv");
  var i;
  for (i = 0; i < publicResult.length; i++) {
    publicResult[i].innerHTML = "";
  }
}

//20 SIDE DICE FUNCTION
function twentySideDiceRoll() {
  //Get dice result
  var result = Math.floor(20 * Math.random() + 1);
  
  //Display dice result on screen
  var publicResult = document.querySelector("#twentySideDiceResult");
  publicResult.innerHTML += "<p> " + result + " </p>";
}

//12 SIDE DICE FUNCTIONS
function twelveSideDiceRoll() {
  //Get dice result
  var result = Math.floor(12 * Math.random() + 1);
  
  //Display dice result on screen
  var publicResult = document.querySelector("#twelveSideDiceResult");
  publicResult.innerHTML += "<p> " + result + " </p>";
}


//10 SIDE DICE FUNCTIONS
function tenSideDiceRoll() {
  //Get dice result
  var result = Math.floor(10 * Math.random() + 1);
  
  //Display dice result on screen
  var publicResult = document.querySelector("#tenSideDiceResult");
  publicResult.innerHTML += "<p> " + result + " </p>";
}


//8 SIDE DICE FUNCTIONS
function eightSideDiceRoll() {
  //Get dice result
  var result = Math.floor(8 * Math.random() + 1);
  
  //Display dice result on screen
  var publicResult = document.querySelector("#eightSideDiceResult");
  publicResult.innerHTML += "<p> " + result + " </p>";
}


//6 SIDE DICE FUNCTIONS
function sixSideDiceRoll() {
  //Get dice result
  var result = Math.floor(6 * Math.random() + 1);
  
  //Display dice result on screen
  var publicResult = document.querySelector("#sixSideDiceResult");
  publicResult.innerHTML += "<p> " + result + " </p>";
}


//4 SIDE DICE FUNCTIONS
function fourSideDiceRoll() {
  //Get dice result
  var result = Math.floor(4 * Math.random() + 1);
  
  //Display dice result on screen
  var publicResult = document.querySelector("#fourSideDiceResult");
  publicResult.innerHTML += "<p> " + result + " </p>";
}
              
            
!
999px

Console