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

              
                <aside style="display: none" id="js-banner" class="banner">
  <div class="banner__inner">
    This browser currently doesn't support Shared Element
    Transitions API. Use Chrome 104+ or Canary with
    <b>chrome://flags/#document-transition</b> enabled to view the
    example.
  </div>
</aside>
<h1>Calvin's super-awesome to-do list</h1>
<section class="grid">
  <article class="col">
    <h2>🤔 To-do</h2>
    <ul>
      <li id="card-1" style="--card-color: #b9fbc0">
        <div class="title">Watch cartoons</div>
        <div class="card-controls">
          <button onclick="moveCard(true)">👍</button>
          <button onclick="moveCard(false)">👎</button>
        </div>
      </li>
      <li id="card-2" style="--card-color: #ffcfd2">
        <div class="title">Play Calvinball</div>
        <div class="card-controls">
          <button onclick="moveCard(true)">👍</button>
          <button onclick="moveCard(false)">👎</button>
        </div>
      </li>
      <li id="card-3" style="--card-color: #98f5e1">
        <div class="title">Build a Transmogrifier</div>
        <div class="card-controls">
          <button onclick="moveCard(true)">👍</button>
          <button onclick="moveCard(false)">👎</button>
        </div>
      </li>
      <li id="card-4" style="--card-color: #cfbaf0">
        <div class="title">Pull a prank on Hobbes</div>
        <div class="card-controls">
          <button onclick="moveCard(true)">👍</button>
          <button onclick="moveCard(false)">👎</button>
        </div>
      </li>

      <li id="card-5" style="--card-color: #fbf8cc">
        <div class="title">Go on a treasure hunt</div>
        <div class="card-controls">
          <button onclick="moveCard(true)">👍</button>
          <button onclick="moveCard(false)">👎</button>
        </div>
      </li>
    </ul>
  </article>

  <article class="col col-complete">
    <h2>😊 Done!</h2>
    <ul id="js-list-done">
      <li style="--card-color: #8eecf5">Wake up early</li>
      <li style="--card-color: #f1c0e8">
        Have sugar bombs for breakfast
      </li>
    </ul>
  </article>

  <article class="col col-complete">
    <h2>😒 Won't-do</h2>
    <ul id="js-list-not-done">
      <li style="--card-color: #eaeaea">Clean my room</li>
      <li style="--card-color: #eaeaea">Go to sleep on time</li>
      <li style="--card-color: #eaeaea">Play with Susie</li>
    </ul>
  </article>
</section>
              
            
!

CSS

              
                li {
  contain: paint;
}

@supports (page-transition-tag: none) {
  ::page-transition-container(card-active) {
    animation-duration: 0.3s;
  }

  ::page-transition-image-wrapper(card-active) {
    animation: popIn 0.3s cubic-bezier(0.64, 0.57, 0.67, 2) 0.1s;
  }
}


@keyframes popIn {
  from {
    transform: scale(1.3);
  }
  to {
    transform: scale(1);
  }
}

@supports not (page-transition-tag: none) {
  .banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #fae588;
    text-align: center;
    z-index: 5;
  }

  .banner__inner {
    padding: 1rem 2rem;
    max-width: 720px;
    margin: 0 auto;
  }

  .banner {
    display: block !important;
  }
}

:root {
  --font-body: "Albert Sans", sans-serif;
  --font-heading: "Indie Flower", cursive;
}

body {
  padding: 3rem 1rem;
  width: 1280px;
  margin: 0 auto;
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
}

h1,
h2 {
  font-family: var(--font-heading);
}

html,
body {
  min-height: 100%;
  background-color: #edf2fb;
}

.grid {
  display: flex;
  gap: 3rem;
  user-select: none;
  align-items: flex-start;
}

h1 {
  margin-bottom: 3rem;
  font-size: 5rem;
  text-align: center;
}

h2 {
  margin-bottom: 1rem;
  font-size: 3.5rem;
}

.col {
  background-color: #fff;
  flex-grow: 1;
  flex-basis: 33.33%;
  border-radius: 8px;
  padding: 2rem 2rem;
  box-shadow: 0 5px 10px 0 #aaa;
  align-items: flex-start;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

li {
  background-color: var(--card-color);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 2rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 21px;
  gap: 1rem;
}

li .title {
  flex-grow: 1;
  line-height: 1.25;
}

button {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 100%;
  cursor: pointer;
  border-width: 0;
  display: flex;
  margin: 0;
  aspect-ratio: 1;
  align-items: center;
  justify-self: center;
}

button:hover {
  background: rgba(0, 0, 0, 0.25);
}

button:active {
  background: rgba(0, 0, 0, 0 0.3);
}

.card-controls {
  display: flex;
  gap: 0.5rem;
  font-size: 14px;
}

.card-moving {
  z-index: 2;
  position:relative;
}

.card-moving .card-controls {
  visibility: hidden;
}

@media (prefers-reduced-motion) {
  ::page-transition-container(*),
  ::page-transition-outgoing-image(*),
  ::page-transition-incoming-image(*) {
    animation: none !important;
  }
}

/*
  1. Use a more-intuitive box-sizing model.
*/
*,
*::before,
*::after {
  box-sizing: border-box;
}
/*
    2. Remove default margin
  */
* {
  margin: 0;
}
/*
    3. Allow percentage-based heights in the application
  */
html,
body {
  height: 100%;
}
/*
    Typographic tweaks!
    4. Add accessible line-height
    5. Improve text rendering
  */
body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-family: Arial, Helvetica, sans-serif;
}
/*
    6. Improve media defaults
  */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}
/*
    7. Remove built-in form typography styles
  */
input,
button,
textarea,
select {
  font: inherit;
}
/*
    8. Avoid text overflows
  */
p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

              
            
!

JS

              
                // Assign unique page-transition-tag values to all task cards
const allCards = document.querySelectorAll(".col:not(.col-complete) li");
allCards.forEach(
  (c, index) => (c.style.pageTransitionTag = `card-${index + 1}`)
);

async function moveCard(isDone) {
  const card = this.window.event.target.closest("li");

  // Get the target list id
  const destination = document.getElementById(
    `js-list-${isDone ? "done" : "not-done"}`
  );

  // We'll use this class to hide the item controls while animation is running
  card.classList.add("card-moving");

  if (document.createDocumentTransition) {
    // Replace the item tag with active (moving) element tag
    card.style.pageTransitionTag = "card-active";

    const moveTransition = document.createDocumentTransition();

    // Run animation
    await moveTransition.start(() => destination.appendChild(card));

    // Remove the tag after animation ends
    card.style.pageTransitionTag = "none";
  } else {
    // Fallback
    destination.appendChild(card);
  }
}

              
            
!
999px

Console