Skip to content

CSS: truncate

.--truncate — קיצוץ עם אליפסיס ומגבלת שורות הנשלטת על ידי --lines — ניתן להשתמש כאלמנט עצמאי או לשרשור על כל קומפוננטה (.instui-button.--truncate).

מחלקת הבסיס משתמשת ב-display: -webkit-box וקוראת את תכונת ה-CSS המותאמת --lines כדי להגביל את הטקסט למספר קבוע של שורות לפני שהוא מסתיים באליפסיס.

Source: index.ts

TIP

דרישת JS — קומפוננטה זו אינה כוללת CSS משלה — הסימון וההתנהגות שלה מגיעים במלואם מ-@pantoken/interactions. המודיפייר --max-lines-auto מונחה על ידי התנהגות זו. ראה את טבלת המודיפיירים למטה.

שימוש

css
@import "@pantoken/components/utilities.css";

דוגמאות

html
<div class="--truncate">This text is clamped to one line by default and ends in an ellipsis.</div>
<div class="--truncate" style="--lines: 3">This text is clamped to three lines and ends in an ellipsis.</div>
<button class="instui-button --truncate">…</button>

מחליפים

מחליףתיאור
.--lines-1כינוי של --max-lines-1.
.--lines-2כינוי של --max-lines-2.
.--lines-3כינוי של --max-lines-3.
.--lines-4כינוי של --max-lines-4.
.--lines-5כינוי של --max-lines-5.
.--max-lines-1הגבלת שורה אחת (ברירת מחדל).
.--max-lines-2הגבלת לשתי שורות.
.--max-lines-3הגבלת לשלוש שורות.
.--max-lines-4הגבלת לארבע שורות.
.--max-lines-5הגבלת לחמש שורות.
.--max-lines-autoInteraction — — Clamp to the number of lines that fit in the container, based on its height and the line height of the text.
.--truncateמאפשר קיצוץ ומגבלת שורות על האלמנט היעד.
.--truncate-character(ברירת מחדל) קיצור ברמת התו.
.--truncate-wordקיצור ברמת המילה.

תכונות מותאמות אישית

תכונהסוגברירת מחדלתיאור
--ellipsisclip | ellipsis | <string> | fadeellipsis
--lines<integer>1

אסימוני צריכה

Tokenסוגערך
--instui-component-truncate-text-font-family[ <font-family-name> | <generic-font-family> ]#Atkinson Hyperlegible Next, "Helvetica Neue", Helvetica, Arial, sans-serif
--instui-line-height-paragraph-base<percentage>150%

תמיכה בדפדפן

  • ההגבלה נשענת על -webkit-line-clamp עם display: -webkit-box, משולבת עם ה-line-clamp הסטנדרטי.

קשור

  • text — טיפוגרפיית גוף שאותה זה מקצר.