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

              
                - let max = 10; //Edit this, purposefully low to show what happens when max is reached. 1000 is fine for me, 10000 isn't

#counter
  - for (let turn = 1; turn <= max; turn++)
    input(type="checkbox" tabindex="-1")
  .blankdec
  .blankinc
  .result
              
            
!

CSS

              
                :root {
  --background:white;
  --background_alt:#E2E2E2;
  --text:black;
  --red:#D8334A;
  --red_alt:#BF263C;
  --green:#A0D468;
  --green_alt:#8CC152;
}
body {
  @include dark { //Dark theme, find toggle bottom right in the pen
    --background:#16181D;
    --background_alt:#313742;
    --text:white;
    --red:#BF263C;
    --red_alt:#D8334A;
    --green:#8CC152;
    --green_alt:#A0D468;
  }
  display:grid;
  place-items:center;
  height:100vh;
  counter-reset: section;
  background:var(--background);
  transition:.25s;
  #counter {
    display:grid;
    grid-template-rows:80px 40px auto;
    grid-gap:10px;
    grid-template-areas:"inc" "dec" "value";
    width:200px;
    padding:10px;
    border:2px solid var(--background_alt);
    border-radius:20px;
    //transform:scale(2); //For video for twitter for followers
    transition:.25s;
    .counter {
      position:fixed;
      top:0px;
    }
    .blankinc, .blankdec { //Shown when there isn't a checkbox to put in its place
      place-items:center;
      opacity:.5;
      border-radius:10px;
      cursor:not-allowed;
      &.blankinc {
        grid-area:inc;
        background:var(--green);
      }
      &.blankdec {
        grid-area:dec;
        background:var(--red);
      }
    }
    .result {
      grid-area:value;
      text-align:center;
      color:var(--text);
      font-size:3rem;
      font-family: 'Quicksand', sans-serif;
      transition:.25s;
      &:before {
        content:counter(section);
      }
    }
    input {
      position:relative;
      z-index:1; //Above blank divs
      appearance:none;
      grid-area:inc; //Overwitten when decrementing
      border-radius:10px;
      cursor:pointer;
      &:before, &:not(:checked):after { //Icon, only unchecked needs both
        content:'';
        position:absolute;
        top:50%;
        left:50%;
        transform:translate(-50%, -50%);
        width:40px;
        height:10px;
        background:var(--background);
        border-radius:10px;
        transition:.25s;
      }
      &:not(:checked):after {
        transform:translate(-50%, -50%) rotate(90deg);
      }
      &:checked {
        counter-increment: section; 
        grid-area:dec; //Checkboxes go under the decrement button and are stacked such that last is top
        //By default inputs are not stacked at the top
        background:var(--red);
        box-shadow:0 0 0 1px var(--background); //This ensures that the checkboxes below don't show through at the corners giving a pixelated look, as they aren't hidden;
        animation:checked .25s;
        transition:box-shadow .25s;
        &:hover {
          background:var(--red_alt);
        }
      }
      &:checked+input:not(:checked), //First unchecked checkbox after checked ones
      &:first-child:not(:checked) { //Or first if unchecked
        background:var(--green);
        &:hover {
          background:var(--green_alt);
        }
        &~input { //All inputs (all unchecked) after are hidden
          display:none;
        }
      }
    }
  }
}
              
            
!

JS

              
                /*
Explanation:

There are a series of checkboxes, when a checkbox is checked it uses `counter-increment: section;` to increment the counter, in essence it allows counting of checked checkboxes. The buttons are checkboxes that change position, with green unchecked at the top and moving to the red checked
The action happens on the boundary of the checked checkboxes on top and the unchecked checkboxes under (it's possible all checkboxes are checked or unchecked, in which no checkboxes may be present on top or bottom and a default blank div is shown)

...
[x] <- These are stacked on the bottom under those after
[x] <- These are stacked on the bottom under those after
[x] <- These are stacked on the bottom with this checkbox clickable as it is stacked on top
[ ] <- These placed on top with this checkbox clickable as others are hidden
[ ] <- These placed on the top but are hidden
[ ] <- These placed on the top but are hidden
...

Checkboxes are stacked by using css grid where multiple elements given the same grid area will stack where the last element is clickable.
With this the checked checkboxes are ordered in a way that is easy to deal with and can be assigned to the decrement area and left. Just need to add a small background coloured shadow to hide the checkboxes stacked under the top giving the corners an ugly pixelated look.
The unchecked checkboxes if left would stack such that the last checkbox would be checked. With the ability to see upward at the checked checkboxes it just requires finding a checked checkbox followed by an unchecked one and select all inputs to hide.
*/
              
            
!
999px

Console