Smooth Scroll Navigation Prompt – AI-Generated Example
Prompt
Create a navigation menu that smoothly scrolls to sections when clicked. Include visual feedback for the active section.
CODE PREVIEW
AIとの対話に追加する一言
プロンプトと一緒にコピーして、AIがより正確に意図を汲み取れるようにします
このコードをそのまま使いたいので、CDNリンクも含めた完全なHTMLファイルとして出力してください。
初心者なので、各行にコメントを追加して、何をしているか説明してください。
このコードをWordPressのテーマに組み込む方法も教えてください。
動作確認済みのコードをお願いします。エラーが出る場合の対処法も含めて。
この実装では、固定ナビゲーションバーとページセクションへのスムーズスクロールを作成します。スクロールまたはクリック時にアクティブなセクションが視覚的に強調表示されます。
Prompt Overview
This prompt targets a classic front-end development task: building a navigation menu that smoothly scrolls the page to corresponding sections when a link is clicked, while also highlighting whichever section is currently in view. It is ideal for landing pages, portfolios, documentation sites, or any single-page layout where guiding users through content without full page reloads improves the overall experience.
To reproduce this effectively, use it with a code-generation model such as GPT-4o or Claude, specifying your preferred stack — vanilla JavaScript, React, or a CSS-only approach. You can extend the prompt by requesting an offset for fixed headers, a scroll-spy mechanism using the Intersection Observer API, or animated underline transitions on active nav items. The output typically includes clean, reusable HTML, CSS, and JavaScript that you can drop directly into an existing project with minimal adjustment.
Was this prompt helpful?
Comments
Comments appear after moderation
この記事が役に立ったら投げ銭で応援
Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済
開発者が選ぶ最強ツール集
運営者が毎日使っているツール・ガジェット 6選