Lenis Smooth Scroll + Parallax Sections: AI Code Example
Prompt
Create a smooth scrolling page using Lenis with parallax sections where background images move at different speeds than the content. Include a simple navigation menu that highlights the current section.
CODE PREVIEW
AIとの対話に追加する一言
プロンプトと一緒にコピーして、AIがより正確に意図を汲み取れるようにします
このコードをそのまま使いたいので、CDNリンクも含めた完全なHTMLファイルとして出力してください。
初心者なので、各行にコメントを追加して、何をしているか説明してください。
このコードをWordPressのテーマに組み込む方法も教えてください。
動作確認済みのコードをお願いします。エラーが出る場合の対処法も含めて。
この実装では、Lenisライブラリを使用したスムーズなスクロール体験とパララックス効果を組み合わせています。4つのフルスクリーンセクションがあり、各セクションの背景画像が前景のコンテンツとは異なる速度で動くことで、奥行きの錯覚を生み出します。
上部に固定されたナビゲーションメニューは、スクロールに応じて現在のセクションを自動的にハイライトし、メニュー項目をクリックするとそのセクションまでスムーズにスクロールします。各セクションではCSS transformを使用してパララックス効果を実現しており、背景画像がコンテンツよりも遅く動くことで3D感を高めています。
Lenisライブラリは設定可能なイージングと期間でバターのように滑らかなスクロールを提供し、パララックス効果は各セクションのスクロール位置に基づいて計算されます。この実装はレスポンシブで、デスクトップとモバイルデバイスの両方で良好に動作します。
Prompt Overview
This prompt instructs an AI coding assistant to build a polished single-page layout that combines Lenis — a lightweight smooth-scroll library — with parallax depth effects, where background images scroll at a slower rate than the foreground content to create a layered, cinematic feel. It also requests a navigation menu that automatically highlights the active section as the user scrolls, a pattern common in modern portfolio sites, agency pages, and product showcases.
The prompt works best with models capable of generating clean HTML, CSS, and JavaScript in a single file, such as GPT-4o or Claude 3.5 Sonnet. It is a strong starting point for frontend developers who want a ready-to-customize scroll experience without wiring up the Lenis integration from scratch. Try extending it by specifying a color scheme, adding scroll-triggered fade-in animations, or swapping static images for video backgrounds to explore richer variations.
Was this prompt helpful?
Comments
Comments appear after moderation
この記事が役に立ったら投げ銭で応援
Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済
開発者が選ぶ最強ツール集
運営者が毎日使っているツール・ガジェット 6選