CSS Accordion Animation: AI-Generated Code Prompt Example
Prompt
Create a smooth CSS-only accordion with animated transitions using details/summary elements and CSS transforms.
CODE PREVIEW
AIとの対話に追加する一言
プロンプトと一緒にコピーして、AIがより正確に意図を汲み取れるようにします
このコードをそのまま使いたいので、CDNリンクも含めた完全なHTMLファイルとして出力してください。
初心者なので、各行にコメントを追加して、何をしているか説明してください。
このコードをWordPressのテーマに組み込む方法も教えてください。
動作確認済みのコードをお願いします。エラーが出る場合の対処法も含めて。
HTML5のdetails/summary要素を使用した純粋なCSSアコーディオンで、スムーズな展開/折りたたみアニメーションを実装しています。JavaScriptは必要ありません。
Prompt Overview
This prompt is designed for front-end developers and UI designers who need a lightweight, JavaScript-free accordion component. By leveraging the native HTML details and summary elements combined with CSS transforms and transitions, it produces a smooth, accessible expand-and-collapse animation without any external dependencies. This approach is ideal for FAQs, sidebars, or any content section where progressive disclosure improves readability.
The resulting code is easy to drop into any project and works reliably across modern browsers. You can extend the base output by adjusting easing curves, adding custom icons, or theming the component to match a design system. This prompt works best with models that have strong CSS knowledge, such as GPT-4 or Claude. Try variations like requesting a multi-level nested accordion, a horizontal slide variant, or a version styled to match a specific color palette to explore the full range of what pure CSS can achieve.
Was this prompt helpful?
Comments
Comments appear after moderation
この記事が役に立ったら投げ銭で応援
Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済
開発者が選ぶ最強ツール集
運営者が毎日使っているツール・ガジェット 6選