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

              
                -
  const rand = (min, max) => {
    return Math.floor(Math.random() * (max - min + 1)) + min;
  }

  const makeRandomScores = () => {
    let scoreArray = [];
    for (let inning = 1; inning < 10; inning++) {
      scoreArray.push(rand(0, 4));
    }
    scoreArray.push(scoreArray.reduce((a, b) => a + b, 0));
    return scoreArray;
  }

  const teams = [
    { "name": "Milwaukee Brewers", scores: makeRandomScores() },
    { "name": "Los Angles Dodgers", scores: makeRandomScores() },
    { "name": "New York Mets", scores: makeRandomScores() },
    { "name": "St. Louis Cardinals", scores: makeRandomScores() },
    { "name": "Houston Astros", scores: makeRandomScores() },
    { "name": "Toronto Blue Jays", scores: makeRandomScores() },
    { "name": "Boston Red Sox", scores: makeRandomScores() },
    { "name": "Chicago Cubs", scores: makeRandomScores() },
    { "name": "Philadelphia Phillies", scores: makeRandomScores() },
    { "name": "Chicago White Sox", scores: makeRandomScores() },
    { "name": "San Diego Padres", scores: makeRandomScores() },
    { "name": "Cleveland Indians", scores: makeRandomScores() },
    { "name": "San Francisco Giants", scores: makeRandomScores() },
    { "name": "Cincinatti Reds", scores: makeRandomScores() },
    { "name": "Minnesota Twins", scores: makeRandomScores() },
    { "name": "Tampa Bay Rays", scores: makeRandomScores() },
    { "name": "Miami Marlins", scores: makeRandomScores() },
    { "name": "Oakland Athletics", scores: makeRandomScores() },
    { "name": "Detroit Tigers", scores: makeRandomScores() },
    { "name": "Pittsburgh Pirates", scores: makeRandomScores() },
    { "name": "Seattle Mariners", scores: makeRandomScores() },
    { "name": "Atlanta Braves", scores: makeRandomScores() }
  ];

div(role="region", aria-labelledby="caption", tabindex="0")
  table
    caption#caption Baseball numbers mmkay.
    thead
      tr
        th Teams
        each val in [1, 2, 3, 4, 5, 6, 7, 8, 9]
          th= val
        th Runs
    tbody
      each team in teams
        tr
          th= team.name
          each score in team.scores
            td= score

              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,700;1,200&display=swap");

table {
  font-family: "Fraunces", serif;
  font-size: 125%;
  white-space: nowrap;
  margin: 0;
  border: none;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  border: 1px solid black;
}
table td,
table th {
  border: 1px solid black;
  padding: 0.5rem 1rem;
}
table thead th {
  padding: 3px;
  position: sticky;
  top: 0;
  z-index: 1;
  width: 25vw;
  background: white;
}
table td {
  background: #fff;
  padding: 4px 5px;
  text-align: center;
}

table tbody th {
  font-weight: 100;
  font-style: italic;
  text-align: left;
  position: relative;
}
table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
}
table tbody th {
  position: sticky;
  left: 0;
  background: white;
  z-index: 1;
}
caption {
  text-align: left;
  padding: 0.25rem;
  position: sticky;
  left: 0;
}

[role="region"][aria-labelledby][tabindex] {
  width: 100%;
  max-height: 98vh;
  overflow: auto;
}
[role="region"][aria-labelledby][tabindex]:focus {
  box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.5);
  outline: 0;
}

              
            
!

JS

              
                
              
            
!
999px

Console