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

              
                <ul class="content">
  <li>
    <h2><a href="https://cupcakeipsum.com/">Cupcake Ipsum</a></h2>
    <p>Cupcake ipsum dolor sit amet sesame snaps jelly candy canes donut. Wafer gingerbread tootsie roll shortbread pie. Brownie dragée dessert gummies croissant oat cake cookie. Chocolate bar jujubes icing tootsie roll brownie.</p>
    <p>Jelly beans ice cream candy bear claw carrot cake pie oat cake macaroon. Cupcake marshmallow carrot cake cupcake marzipan. Lemon drops caramels tootsie roll gingerbread bear claw bear claw jelly sweet.</p>
  </li>
  
  <li>
    <h2><a href="http://herpderpsum.com/">Herp Derpsum</a></h2>
    <p>Herp derpsum sherp cerp herpsum derpy tee. Derps de se derp sherp sherlamer terpus. Tee merp perp herpem derperker. Derpsum merp le perper sherp zerpus. Herpderpsmer sherper re perp dippy derpy derp derpsum.</p>
    <p>Ner sherlamer derps perp. Herpderpsmer derperker perper sherpus! Sherlamer zerpus er perp derpy derps pee terp. De pee zerpus cerp. Herpy terpus herp ner derpler! Jerpy herpderpsmer re! Derpy dippy diddium.</p>
  </li>

  <li>
    <h2><a href="http://saganipsum.com/">Sagan Ipsum</a></h2>
    <p>Hypatia tingling of the spine a mote of dust suspended in a sunbeam Apollonius of Perga the only home we've ever known culture. Stirred by star stuff harvesting star light descended from astronomers rich in mystery.</p>
    <p>With pretty stories for which there's little good evidence preserve and cherish that pale blue dot emerged into consciousness a still more glorious dawn awaits vastness is bearable only through love take root and flourish.</p>
  </li>

  <li>
    <h2><a href="https://baconipsum.com/">Bacon Ipsum</a></h2>
    <p>Bacon ipsum dolor amet doner turkey tenderloin tri-tip spare ribs brisket short ribs turducken ribeye rump shankle frankfurter beef meatball. Hamburger filet mignon jerky flank shoulder, pork spare ribs bresaola buffalo.</p>
    <p>Strip steak drumstick meatloaf porchetta swine, tongue fatback ball tip. Rump chislic kevin filet mignon burgdoggen chuck, strip steak brisket ground round andouille. Landjaeger meatloaf buffalo chuck frankfurter sirloin.</p>
  </li>

  <li>
    <h2><a href="http://nietzsche-ipsum.com/">Nietzsche Ipsum</a></h2>
    <p>Law inexpedient noble reason abstract revaluation war salvation snare burying merciful love inexpedient strong. Inexpedient prejudice ideal victorious deceptions good holiest. Faithful philosophy endless fearful enlightenment.</p>
    <p>Right depths philosophy derive society insofar chaos intentions joy. Morality moral war eternal-return depths sea morality noble free disgust sea zarathustra. Moral ubermensch battle prejudice ultimate ascetic.</p>
  </li>
  
  <li>
    <h2><a href="https://makesum.com/viking">Viking Ipsum</a></h2>
    <p>Axes skald lack horns terror, Northumbria swords besta Leif Erikson the kracken. Kleppstad pax bjorn the chair Ragnar Lothbrok sailing, raiding runic Leif Erikson sea Thor. King Alfred pax sailing horns loot Dane.</p>
    <p>Hej kura tall blond women berserker ocean Beowulf Beowulf malm the kracken. Skald terror rune Northumbria, kallax Beowulf swords Beowulf malm besta kura longship. Besta loot Northumbria berserker Uppsala.</p>
  </li>
</ul>
              
            
!

CSS

              
                body {
  font-family: Arial, sans-serif;
}

li {
  background: #f7f7f7;
  padding: 20px;
  display: grid;
  gap: 1em;
}

.content {
  display: grid;
  gap: 20px;
  margin: 0;
  list-style: none;
  padding: 20px;
}

p, h2 {margin: 0;}

.pagination {
  text-align: center;
  margin-top: 20px;
}

.pagination button {
  padding: 5px 10px;
  margin: 0 5px;
  cursor: pointer;
  outline: 1px solid #494a4f;
  border-radius: 1px;
  border: none;
}

.hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.pagination button.active {
  background-color: #007bff;
  color: white;
}

a {
  color: #2196F3;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

              
            
!

JS

              
                document.addEventListener('DOMContentLoaded', function () {
  const content = document.querySelector('.content'); 
  const itemsPerPage = 2; // set number of items per page
  let currentPage = 0;
  const items = Array.from(content.getElementsByTagName('li')).slice(0);

function showPage(page) {
  const startIndex = page * itemsPerPage;
  const endIndex = startIndex + itemsPerPage;
  items.forEach((item, index) => {
    item.classList.toggle('hidden', index < startIndex || index >= endIndex);
  });
  updateActiveButtonStates();
}

function createPageButtons() {
  const totalPages = Math.ceil(items.length / itemsPerPage);
  const paginationContainer = document.createElement('div');
  const paginationDiv = document.body.appendChild(paginationContainer);
  paginationContainer.classList.add('pagination');

  // Add page buttons
  for (let i = 0; i < totalPages; i++) {
    const pageButton = document.createElement('button');
    pageButton.textContent = i + 1;
    pageButton.addEventListener('click', () => {
      currentPage = i;
      showPage(currentPage);
      updateActiveButtonStates();
    });

      content.appendChild(paginationContainer);
      paginationDiv.appendChild(pageButton);
    }
}

function updateActiveButtonStates() {
  const pageButtons = document.querySelectorAll('.pagination button');
  pageButtons.forEach((button, index) => {
    if (index === currentPage) {
      button.classList.add('active');
    } else {
      button.classList.remove('active');
    }
  });
}

  createPageButtons(); // Call this function to create the page buttons initially
  showPage(currentPage);
});

              
            
!
999px

Console