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

              
                <div class="container">スクロールして下さい↓</div>
<div class="text-container">
  <p class="js-text">じゅんぺいブログ</p>
</div>
<div class="container">終わり</div>

              
            
!

CSS

              
                .container {
  align-items: center;
  background-color: #ccc;
  display: flex;
  font-size: clamp(30px, 5vw, 50px);
  height: 100vh;
  justify-content: center;
}
.text-container {
  align-items: center;
  display: flex;
  height: 100vh;
  justify-content: center;
}
p {
  color: #333;
  font-size: clamp(30px, 5vw, 50px);
  font-weight: 700;
  letter-spacing: .2em;
  text-align: center;
}
span {
  display: inline-block;
}

              
            
!

JS

              
                // 対象の要素を取得
const paragraph = document.querySelector(".js-text");

// テキストコンテンツを取得
const textContent = paragraph.textContent;

// テキストコンテンツを一文字ずつ分割して<span>タグで囲んで新しい文字列を作成
const newTextContent = [...textContent]
  .map((char) => `<span>${char}</span>`)
  .join("");
// 新しい文字列をHTMLに挿入
paragraph.innerHTML = newTextContent;

gsap.fromTo(
  ".js-text span", // アニメーションさせる要素
  {
    autoAlpha: 0, // アニメーション開始前は透明
    y: -100, // 100px上に移動
  },
  {
    autoAlpha: 1, // アニメーション後は出現(透過率0)
    y: 0, // 100px下に移動
    stagger: 0.2, // 0.2秒遅れて順番に再生
    ease: "bounce.out", // イージング
    scrollTrigger: {
      trigger: ".js-text span", // アニメーションが始まるトリガーとなる要素
      start: "bottom center", // アニメーションが始まる位置
      markers: true, // マーカー表示
    },
  }
);
              
            
!
999px

Console