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

              
                <section class="section">
    <div class="title">
        <p class="title__en js-splitText js-text-effect" id="01">Home</p>
        <h2 class="title__jp">ホーム</h2>
    </div>
</section>
<section class="section">
    <div class="title">
        <p class="title__en js-splitText js-text-effect" id="02">About</p>
        <h2 class="title__jp">わたしたちについて</h2>
    </div>
</section>
<section class="section">
    <div class="title">
        <p class="title__en js-splitText js-text-effect" id="03">Service</p>
        <h2 class="title__jp">サービス</h2>
    </div>
</section>
<section class="section">
    <div class="title">
        <p class="title__en js-splitText js-text-effect" id="04">News</p>
        <h2 class="title__jp">お知らせ</h2>
    </div>
</section>
<section class="section">
    <div class="title">
        <p class="title__en js-splitText js-text-effect" id="05">Recruit</p>
        <h2 class="title__jp">採用情報</h2>
    </div>
</section>
<section class="section">
    <div class="title">
        <p class="title__en js-splitText js-text-effect" id="06">Thank you!</p>
        <h2 class="title__jp">最後まで見てくれてありがとう!!</h2>
    </div>
</section>
              
            
!

CSS

              
                 @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@900&display=swap');
*{
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
html{
    scroll-behavior: smooth;
    scroll-padding-top: 45vh;
}
body{
    background-color: #333;
}
.section{
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50vh 0;
}
.section:last-child{
    padding-bottom: 50vh;
}
.title__en{
    font-size: 64px;
    font-weight: bold;
    font-family: 'Montserrat', sans-serif;
    color: white;
}
.title__jp{
    font-size: 18px;
    color: gold;
}

/* ここまでは見た目を整える記述 */
.js-text-effect span{
    display: inline-block;//必須
    opacity: 0;
    visibility: visible;
    transform: rotateY(90deg);
}
              
            
!

JS

              
                /* spanタグに分割 */
let splitTarget = document.querySelectorAll('.js-splitText');//ターゲットとなる要素を全取得
splitTarget.forEach((target) => {// target = ターゲット
    if(!target.classList.contains('is-active')){//ターゲットが'is-active'クラスを持っていない場合
        newText = '';//生成する要素を格納するための変数
        spanText = target.innerHTML;//ターゲットの中身を取得
        spanText.split('').forEach((char) => {// char = character 文字
            newText += '<span>' + char + '</span>';//一文字ずつspanタグで囲む
        });
        target.innerHTML = newText;//ターゲットに生成した要素を挿入
    }
});

let textEffect = document.querySelectorAll('.js-text-effect');//ターゲットとなる要素を全取得
textEffect.forEach((target)=>{
    let spans = target.querySelectorAll('span');
    gsap.to(spans,{duration:0.5,autoAlpha:1,rotateY:'0deg',
        stagger:{
            each:0.1
        },
        scrollTrigger:{
            trigger:target,
            start:'bottom bottom',
        }    
    })
})
              
            
!
999px

Console