Lenis Smooth Scroll + Parallax Sections: AI Code Example
CODE PREVIEW
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.
この実装では、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選