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="shader"></div>
<h2>Random Number Generator</h2>
    <h3>between 1 and <span id="placeholder">10</span></h3>
    <div class="wrapper">
        <div id="r-container">
            <span id="rand"></span>
        </div>
        <div class="i-container">
            <input onChange="onChange()" type="number" value="10" />
            <button id="button" onclick="random()">Generate</button>
            <div class="reset"><span onclick="resetLi()">Reset</span></div>
        </div>
        <div class="l-container">
            <ul id="list">

            </ul>
        </div>
</div>
              
            
!

CSS

              
                * {
    box-sizing: border-box;
}

@mixin flexAlignCenter() {
    display: flex;
    justify-content: center;
    align-items: center;
}

@mixin mobile {
    @media (min-width: 769px) {
        @content;
    }
}

body {
    &::-webkit-scrollbar {
        width: 0;
    }
  font-family:sans-serif;
    background:url("https://picsum.photos/1000/1000");
  background: radial-gradient(
      circle,
      #947eb0 16%,
      #fcfcfc 24%,
      #5eb1bf 3%,
      #042a2b 13%,
      #c2a878 74%
    );
    background-attachment:fixed;
    background-position:center;
    background-repeat:none;
    background-size:cover;
    transition: boxShadow 3s;
    margin: 0;
    padding: 0;
    color: white;
    background-color: black;
    min-height: 100vh;
  .shader{
    background-color:#000000bb;
    position:fixed;
    top:0;
    left:0;
    width:100vw;
    height:100vh;
    z-index:-1;
    
  }
    h2 {
        text-align: center;
        margin-top: 0;
        padding-top: 1rem;
    }
    h3 {
        text-align: center;
    }
    $fontsize: 3vw;
    $m-font:1.5vw;
    @mixin fontsize {
        font-size: $fontsize;
        @include mobile() {
            font-size: $m-font;
        }
    }
    #r-container {
        @include flexAlignCenter();
        min-height: 10vh;
      margin:3rem 0;
        span {
            text-align: center;
          font-size:5rem;
            // @include fontsize();
        }
    }
    $fontsize: 3vw;
    $m-font:2vw;
    @mixin fontsize {
        font-size: $fontsize;
        @include mobile() {
            font-size: $m-font;
        }
    }
    .i-container {
        min-height: 2rem;
        @include flexAlignCenter();
        input {
          outline: none;
          border: none;
          color:white;
          background-color:transparent;
          // border:solid 1px white;
          border-bottom:1px white solid;
          text-align:center;
          width:7rem;
          @include fontsize();
        }
        @mixin hover {
            transition: transform .15s;
            &:hover {
                transform: translateY(-3.5px);
            }
        }
        button {
            background: transparent;
            font-size: $fontsize;
            color: white;
            outline: none;
            border: none;
            margin: 0 .5rem;
            padding: 1% 2%;
            cursor: pointer;
            @include hover();
            @include fontsize();
        }
        .reset {
            text-align: center;
            font-size: $fontsize;
            @include hover();
            @include fontsize();
            span {
                cursor: pointer;
            }
        }
    }
    .l-container {
        @include mobile() {
            padding: 0 5%;
        }
        #list {
            display: flex;
            flex-wrap: wrap;
            li {
                margin: .5rem 1rem;
                @include fontsize();
            }
        }
    }
}
              
            
!

JS

              
                var input = document.querySelector("input");
var number = input.value;
var placeholder = document.getElementById("placeholder");
var list = document.getElementById("list");
var rand = document.querySelector("#rand");
var reset = document.querySelector(".reset");
var button = document.getElementById("button");
var body = document.querySelector("body");
// var colors = ["lightblue", "aquamarine", "pink", "bisque", "white"];
var colors = ['#FF6633', '#FFB399', '#FF33FF', '#FFFF99',
              '#00B3E6',
		  '#E6B333', '#3366E6', '#999966', '#99FF99', '#B34D4D',
		  '#80B300', '#809900', '#E6B3B3', '#6680B3', '#66991A', 
		  '#FF99E6', '#CCFF1A', '#FF1A66', '#E6331A', '#33FFCC',
		  '#66994D', '#B366CC', '#4D8000', '#B33300', '#CC80CC', 
		  '#66664D', '#991AFF', '#E666FF', '#4DB3FF', '#1AB399',
		  '#E666B3', '#33991A', '#CC9999', '#B3B31A', '#00E680', 
		  '#4D8066', '#809980', '#E6FF80', '#1AFF33', '#999933',
		  '#FF3380', '#CCCC00', '#66E64D', '#4D80CC', '#9900B3', 
		  '#E64D66', '#4DB380', '#FF4D4D', '#99E6E6', '#6666FF'];

function onChange() {
  number = input.value;
  placeholder.innerHTML = number
}

function random() {
  rand.innerHTML = Math.ceil(Math.random() * number)
  var text = document.createTextNode(rand.innerHTML)
  var node = document.createElement("LI");
  node.appendChild(text);
  console.log(node)
  var randNumber = Math.floor(Math.random() * colors.length);
  var randNum = Math.floor(Math.random() * colors.length);
  node.style.color = colors[randNumber];
  reset.style.color = colors[randNum];
  button.style.border = "solid 1px" + " " + colors[randNumber];
  body.style.boxShadow = "inset 0 0 500px -200px" + " " + colors[randNumber]
  list.appendChild(node)
}

function resetLi() {
  document.querySelectorAll("li").forEach((e, i, _p) => {
    e.remove();
  })
  document.querySelector("#rand").innerHTML = ""
}
              
            
!
999px

Console