Responsive Cards with Container Queries
Prompt
Create an interactive playground demonstrating CSS Container Queries. The page should have a container with resizable width (via slider or dragged handle), and cards inside that change layout based on the container's width (not the viewport). Include at least two breakpoints (e.g., card width < 300px: stacked vertical layout; >= 300px: horizontal row with image left; >= 500px: horizontal with larger thumbnail and text). Use container-type: inline-size, container-name, and @container rules. Add a small preview panel showing current container width. Use a clean, modern design with subtle colors. No JS framework, pure HTML/CSS/JS.
CODE PREVIEW
AIとの対話に追加する一言
プロンプトと一緒にコピーして、AIがより正確に意図を汲み取れるようにします
このコードをそのまま使いたいので、CDNリンクも含めた完全なHTMLファイルとして出力してください。
初心者なので、各行にコメントを追加して、何をしているか説明してください。
このコードをWordPressのテーマに組み込む方法も教えてください。
動作確認済みのコードをお願いします。エラーが出る場合の対処法も含めて。
このインタラクティブプレイグラウンドでは、CSS Container Queries の挙動を体験できます。従来のビューポート基準ではなく、親コンテナの幅に応じて要素のレイアウトが変化します。スライダーでコンテナ幅を調整すると、300px・500px のブレークポイントでカードが縦積み→横並び→大きなサムネイル付きに変化します。
Prompt Overview
This interactive playground demonstrates CSS Container Queries, a powerful new responsive design technique. Instead of relying on viewport size, container queries allow elements to adapt based on the size of their parent container. In this example, cards inside a resizable container change layout at 300px and 500px breakpoints — from stacked vertical to horizontal with image, and finally to a larger thumbnail layout. Use the slider to adjust the container width and observe the responsive behavior in real-time.
Was this prompt helpful?
Comments
Comments appear after moderation
この記事が役に立ったら投げ銭で応援
Apple Pay / Google Pay / カード (Visa/Mastercard/JCB/Amex) / Link / Alipay / WeChat Pay 対応 · Stripeで安全に決済
開発者が選ぶ最強ツール集
運営者が毎日使っているツール・ガジェット 6選