複数行のプレビュー
CoddyのTailwind CSSジャーニー「レスポンシブUIパターン」セクションの一部。レッスン 33/55。
カードの説明には、1行に切り詰めたラベルではなく、数行が必要な場合があります。line-clamp-2はテキストブロックを表示上2行に制限し、残りを切り詰めますが、全文はドキュメント内に残します。この例では、プレビューの横に説明全文へのリンクを配置しています。
<article><p class="line-clamp-2 leading-6">A longer event description appears here.</p><a href="#details">Read the full description</a></article>プレビューの役割に応じて行数を選びましょう。line-clamp-3では3行まで表示され、line-clamp-noneでは行数制限が解除され、通常のオーバーフロー表示に戻ります。画面幅に応じたバリアントを使うと、より広いスペースが使える場合に、狭い画面向けのプレビュー制限を解除できます。
クランプは要約のために使うものであり、重要な指示やエラーを隠すために使うものではありません。全文にアクセスできるようにしてください。行の高さが分かっていれば、1行あたりの文字数を特定の値と仮定しなくても、プレビューの想定される高さを簡単に確認できます。
チャレンジ
中級提供された説明のプレビューを、既存の24pxの行の高さのまま3行に制限してください。全文と全文説明へのリンクはそのままにしてください。カードが拡張するのではなく、プレビューのはみ出し部分を切り取る必要があります。
提供されたコンテンツ、セマンティック要素、IDはそのままにしてください。指定されたユーティリティクラスを編集してください。編集後に「実行」でプレビューし、その後「確認」/「コードを実行」で結果を採点してください。提供されたJavaScriptは読み取り専用です。
機能する全文説明へのリンクと、行数制限のない全文のリンク先を引き続き利用できるようにしてください。
自分で試してみよう
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Interface workshop</title><link rel="stylesheet" href="./styles.css"></head><body>
<article class="w-48"><p id="summary" class="leading-6 ">A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. </p><a href="#full">Read full description</a></article>
<section id="full" tabindex="-1" class="mt-8"><h2>Full workshop description</h2><p id="fullText">A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. A hands-on workshop explores drawing, printing, color mixing, composition and collaborative studio practice. Bring a notebook and discover several approaches with the teaching team. </p></section></body></html>
このレッスンには短いクイズがあります。レッスンを始めて解答し、進捗を記録しましょう。