Pen Settings



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


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


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.


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.


                    <div class="counter-container">
      <div class="counter" data-target="22000"></div>

    <div class="counter-container">
      <div class="counter" data-target="1300"></div>

    <div class="counter-container">
      <div class="counter" data-target="9500"></div>



                * {
  box-sizing: border-box;
:root {
  --color-bg: #EAEAEA;
  --color-text: #ADA996;

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
  margin: 0;

.counter-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  margin: 10px 20px;
  & .counter {
    font-size: 1.6rem;
    font-weiht: bold
button {
  position: absolute;
  color: var(--color-text);
  bottom: 5%;
  left: 50%;
  background: #F2F2F2;
  transform: translateX(-50%);
  cursor: pointer;
  border: 1px sollid var(--color-text);
  border-radius: 2rem;
  padding: 1rem 1.5rem;
  font-size: 1.5rem;



                const btn = document.querySelector("button");
const counters = document.querySelectorAll(".counter");

btn.addEventListener("click", setCounter, false);

function setCounter() {
  counters.forEach((counter) => {
    // 初期値を設定
    counter.innerText = "0";

    const updateCounter = () => {
      // data属性の値を取得
      const targetNum = +counter.getAttribute("data-target");
      // テキストに挿入する変数(+で数値に変換)
      const displayNum = +counter.innerText;
      // スピードの設定
      const SPEED = 250;
      // 増加を定義
      const increment = targetNum / SPEED;

      // ターゲットに到達していない場合
      if (displayNum < targetNum) {
        // 整数に変換して挿入
        counter.innerText = `${Math.ceil(displayNum + increment)}`;
        setTimeout(updateCounter, 1);
      } else {
        counter.innerText = targetNum;

    // 処理が終わるまで呼び出す