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>
  <h1 id="pageHeader">Aaron's Game Dice Set</h1>
  <p id="headerIntro">A Dice Set for Dungeons & Dragons</p>
  
  <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>
        <button class="removeButton" value="delete" onclick="twentySideDiceDelete()">Delete Values</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>
        <button class="removeButton" value="delete" onclick="twelveSideDiceDelete()">Delete Values</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>
        <button class="removeButton" value="delete" onclick="tenSideDiceDelete()">Delete Values</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>
        <button class="removeButton" value="delete" onclick="eightSideDiceDelete()">Delete Values</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>
        <button class="removeButton" value="delete" onclick="sixSideDiceDelete()">Delete Values</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>
        <button class="removeButton" value="delete" onclick="fourSideDiceDelete()">Delete Values</button>
        <div class="classResultDiv" id="fourSideDiceResult"></div>
      </section>
    </div>
  </div>
</body>

<footer>
  <div id="footerDiv">
    <p class="footerText">Version 1.0</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;
}

#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

              
                function deleteValues() {
  var publicResult = document.querySelector(".classResultDiv");
  publicResult.innterHTML = "";
}

//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>";
}

function twentySideDiceDelete() {
  var publicResult = document.querySelector("#twentySideDiceResult");
  publicResult.innerHTML = "";
}

//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>";
}

function twelveSideDiceDelete() {
  var publicResult = document.querySelector("#twelveSideDiceResult");
  publicResult.innerHTML = "";
}

//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>";
}

function tenSideDiceDelete() {
  var publicResult = document.querySelector("#tenSideDiceResult");
  publicResult.innerHTML = "";
}

//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>";
}

function eightSideDiceDelete() {
  var publicResult = document.querySelector("#eightSideDiceResult");
  publicResult.innerHTML = "";
}


//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>";
}

function sixSideDiceDelete() {
  //remove dice value from page
  var publicResult = document.querySelector("#sixSideDiceResult");
  publicResult.innerHTML = "";
}

//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>";
}

function fourSideDiceDelete() {
  //remove dice value from page
  var publicResult = document.querySelector("#fourSideDiceResult");
  publicResult.innerHTML = "";
}
              
            
!
999px

Console