aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/css/text-overflow
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/fr/web/css/text-overflow
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/fr/web/css/text-overflow')
-rw-r--r--files/fr/web/css/text-overflow/index.html343
1 files changed, 343 insertions, 0 deletions
diff --git a/files/fr/web/css/text-overflow/index.html b/files/fr/web/css/text-overflow/index.html
new file mode 100644
index 0000000000..cd18e2e925
--- /dev/null
+++ b/files/fr/web/css/text-overflow/index.html
@@ -0,0 +1,343 @@
+---
+title: text-overflow
+slug: Web/CSS/text-overflow
+tags:
+ - CSS
+ - Propriété
+ - Reference
+translation_of: Web/CSS/text-overflow
+---
+<div>{{CSSRef}}</div>
+
+<p>La propriété <strong><code>text-overflow</code></strong> définit la façon dont le contenu textuel qui dépasse d'une boîte est signalé pour les utilisateurs. Le texte peut être rogné (<em>clipping</em>), afficher une ellipse ('<code>…</code>', <code style="text-transform: uppercase;">U+2026 Horizontal Ellipsis</code>) ou afficher une chaîne de caractères choisie.</p>
+
+<div>{{EmbedInteractiveExample("pages/css/text-overflow.html")}}</div>
+
+<p class="hidden">Le code source de cet exemple interactif est disponible dans un dépôt GitHub. Si vous souhaitez contribuez à ces exemples, n'hésitez pas à cloner <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> et à envoyer une <em>pull request</em> !</p>
+
+<p>Le rognage se fera à la bordure de la boîte. Afin que le rognage se fasse plus tôt, à la limite des caractères, on peut utiliser la chaîne vide (<code>''</code>).</p>
+
+<p>Cette propriété n'affecte que le contenu qui dépasse de la boîte englobante dans le sens de la progression en ligne. Par exemple, on ne parle pas ici du texte qui dépasserait vers le bas d'une boîte. Le texte peut dépasser lorsqu'on empêche le retour automatique à la ligne (par exemple avec <code class="css">white-space: nowrap</code>) ou lorsqu'un seul mot est trop long pour tenir dans le conteneur.</p>
+
+<p>Cette  propriété CSS ne force pas le dépassement. Pour ce faire et afin que <code>text-overflow</code> soit appliqué, l'auteur devra ajouter des propriétés supplémentaires sur l'élément, notamment : {{cssxref("overflow")}} avec <code>hidden</code> et {{cssxref("white-space")}} avec <code>nowrap</code>.</p>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="brush: css no-line-numbers">/* On gère le dépassement en fin de ligne
+ - à droite en LTR,
+ - à gauche en RTL */
+text-overflow: clip;
+text-overflow: ellipsis;
+text-overflow: "…";
+text-overflow: fade;
+text-overflow: fade(10px);
+text-overflow: fade(5%);
+
+/* On gère le dépassement au début et
+ à la fin de la ligne. La directionnalité
+ n'a pas d'importance */
+text-overflow: clip ellipsis;
+text-overflow: "…" "…";
+text-overflow: fade clip;
+text-overflow: fade(10px) fade(10px);
+text-overflow: fade(5%) fade(5%);
+
+/* Valeurs globales */
+text-overflow: inherit;
+text-overflow: initial;
+text-overflow: unset;
+</pre>
+
+<p>La propriété <code>text-overflow</code> peut être définie grâce à une ou deux valeurs.</p>
+
+<p>Si une valeur est fournie, celle-ci indique le comportement du dépassement en fin de ligne (c'est-à-dire l'extrêmité droite pour les textes écrits de gauche à droite et l'extrêmité gauche pour les textes écrits de droite à gauche). Si deux valeurs sont fournies, la première précisera la comportement pour le dépassement à l'extrêmité gauche de la ligne et la seconde indiquera le comportement du dépassement pour l'extrêmité droite de la ligne.</p>
+
+<p>Chacune des valeurs se compose :</p>
+
+<ul>
+ <li>D'un des mots-clés : <code><a href="#clip">clip</a></code>, <code><a href="#ellipsis">ellipsis</a></code>, <code><a href="#fade">fade</a></code></li>
+ <li>De la fonction <code><a href="#fade_fun">fade()</a></code> à laquelle on passe une valeur de type {{cssxref("&lt;length&gt;")}} ou {{cssxref("&lt;percentage&gt;")}} qui permet de contrôler la distance d'effacement</li>
+ <li>D'<a href="#string">une chaîne de caractères <code>&lt;string&gt;</code></a>.</li>
+</ul>
+
+<h3 id="Valeurs">Valeurs</h3>
+
+<dl>
+ <dt><a id="clip" name="clip"><code>clip</code></a></dt>
+ <dd>La valeur par défaut de cette propriété. Ce mot-clé indique qu'on tronque le texte à la limite de <a href="/fr/Apprendre/CSS/Les_bases/Le_modèle_de_boîte">la boîte de contenu</a>. La troncature peut donc arriver sur le milieu d'un caractère. Pour que celle-ci soit appliquée entre deux caractères, on devra utiliser la chaîne vide (<code>''</code>) comme valeur pour cette propriété.</dd>
+ <dt><a id="ellipsis" name="ellipsis"><code>ellipsis</code></a></dt>
+ <dd>Ce mot-clé indique qu'on affiche une ellipse (<code>'…'</code>, <code style="text-transform: uppercase;">U+2026 Horizontal Ellipsis</code>) pour représenter le texte rogné. L'ellipse est affichée à l'intérieur de <a href="/fr/Apprendre/CSS/Les_bases/Le_modèle_de_boîte">la boîte de contenu</a> et réduit donc la quantité de texte affichée. S'il n'y a pas assez de place pour afficher l'ellipse, celle-ci est rognée.</dd>
+ <dt><a id="fade" name="fade"><code>fade</code></a> {{experimental_inline}}</dt>
+ <dd>Ce mot-clé indique que le contenu qui dépasse est rogné avec un effet de dégradé en transparence. Au bout de la boîte, le contenu est totalement transparent.</dd>
+ <dt><a id="fade_fun" name="fade_fun"><code>fade( &lt;length&gt; | &lt;percentage&gt; )</code></a> {{experimental_inline}}</dt>
+ <dd>Cette fonction permet de rogner le contenu qui dépasse et d'appliquer un effet de dégradé en transparence. Au bout de la boîte, on a une transparence totale.<br>
+ L'argument passé à la fonction détermine la distance sur laquelle cet effet est appliqué. La valeur en pourcentage est relative à la largeur de la boîte. Les valeurs inférieures à <code>0</code> sont ramenées à <code>0</code>. Les valeurs supérieures à la largeur de la boîte sont écrétées à la largeur de la boîte.</dd>
+ <dt><a id="string" name="string"><code>&lt;string&gt;</code></a> {{experimental_inline}}</dt>
+ <dd>Une chaîne de caractères (type {{cssxref("&lt;string&gt;")}}) utilisée pour représentée le texte rogné. La chaîne est affichée à l'intérieur de <a href="/fr/Apprendre/CSS/Les_bases/Le_modèle_de_boîte">la boîte de contenu</a> et réduit donc la quantité de texte affichée. S'il n'y a pas assez de place pour afficher la chaîne choisie, celle-ci est rognée.</dd>
+</dl>
+
+<h3 id="Syntaxe_formelle">Syntaxe formelle</h3>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="Exemples">Exemples</h2>
+
+<h3 id="CSS">CSS</h3>
+
+<pre class="brush: css">p {
+ width: 200px;
+ border: 1px solid;
+ padding: 2px 5px;
+
+ /* Nécessaires pour text-overflow */
+ white-space: nowrap;
+ overflow: hidden;
+}
+
+.overflow-visible {
+ white-space: initial;
+}
+
+.overflow-clip {
+ text-overflow: clip;
+}
+
+.overflow-ellipsis {
+ text-overflow: ellipsis;
+}
+
+.overflow-string {
+ /* Cette forme n'est pas prise en charge
+ par la plupart des navigateurs. cf. la
+ section Compatibilité ci-après */
+ text-overflow: " [..]";
+}
+</pre>
+
+<h3 id="HTML">HTML</h3>
+
+<pre class="brush: html">&lt;p class="overflow-visible"&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit.&lt;/p&gt;
+
+&lt;p class="overflow-clip"&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit.&lt;/p&gt;
+
+&lt;p class="overflow-ellipsis"&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit.&lt;/p&gt;
+
+&lt;p class="overflow-string"&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit.&lt;/p&gt;
+</pre>
+
+<h3 id="Résultat">Résultat</h3>
+
+<p>{{EmbedLiveSample('Exemples', 300, 220, '', 'Web/CSS/text-overflow')}}</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th colspan="1" rowspan="2" scope="col">Valeur CSS</th>
+ <th colspan="2" rowspan="1" scope="col" style="text-align: center;"><code>direction: ltr</code></th>
+ <th colspan="2" rowspan="1" scope="col" style="text-align: center;"><code>direction: rtl</code></th>
+ </tr>
+ <tr>
+ <th scope="col">Résultat attendu</th>
+ <th scope="col">Résultat du navigateur</th>
+ <th scope="col">Résultat attendu</th>
+ <th scope="col">Résultat du navigateur</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>overflow:visible</code></td>
+ <td style="font-family: monospace;">1234567890</td>
+ <td style="direction: ltr;">
+ <div style="float: left; font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: visible;"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">0987654321</td>
+ <td>
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: visible;"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: clip</code></td>
+ <td style="padding: 1px; font-family: monospace;"><img alt="t-o_clip.png" class="default internal" src="/@api/deki/files/6056/=t-o_clip.png"></td>
+ <td style="direction: ltr;">
+ <div style="float: left; font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: clip;">123456</div>
+ </td>
+ <td style="padding: 1px; font-family: monospace;"><img alt="t-o_clip_rtl.png" class="default internal" src="/@api/deki/files/6057/=t-o_clip_rtl.png"></td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: clip;"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: ''</code></td>
+ <td style="font-family: monospace;">12345</td>
+ <td style="direction: ltr;">
+ <div style="float: left; font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: '';">123456</div>
+ </td>
+ <td style="font-family: monospace;">54321</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: '';"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: ellipsis</code></td>
+ <td style="font-family: monospace;">1234…</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ellipsis;"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">…4321</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ellipsis;"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: '.'</code></td>
+ <td style="font-family: monospace;">1234.</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: '.';"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">.4321</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: '.';"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: clip clip</code></td>
+ <td style="font-family: monospace;">123456</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: clip clip;"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">654321</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: clip clip;"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: clip ellipsis</code></td>
+ <td style="font-family: monospace;">1234…</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: clip ellipsis;"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">6543…</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: clip ellipsis;"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: clip '.'</code></td>
+ <td style="font-family: monospace;">1234.</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: clip '.';"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">6543.</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: clip '.';"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: ellipsis clip</code></td>
+ <td style="font-family: monospace;">…3456</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ellipsis clip;"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">…4321</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ellipsis clip;"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: ellipsis ellipsis</code></td>
+ <td style="font-family: monospace;">…34…</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ellipsis ellipsis;"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">…43…</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ellipsis ellipsis;"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: ellipsis '.'</code></td>
+ <td style="font-family: monospace;">…34.</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ellipsis '.';"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">…43.</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ellipsis '.';"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: ',' clip</code></td>
+ <td style="font-family: monospace;">,3456</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ',' clip;"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">,4321</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ',' clip;"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: ',' ellipsis</code></td>
+ <td style="font-family: monospace;">,34…</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ','ellipsis;"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">,43…</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ','ellipsis;"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ <tr>
+ <td><code>text-overflow: ',' '.'</code></td>
+ <td style="font-family: monospace;">,34.</td>
+ <td style="direction: ltr;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ',' '.';"><span style="direction: ltr; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ <td style="font-family: monospace;">,43.</td>
+ <td style="direction: rtl;">
+ <div style="font-family: monospace; white-space: nowrap; max-width: 3.35em; overflow: hidden; text-overflow: ',' '.';"><span style="direction: rtl; margin: 0 -2px; unicode-bidi: bidi-override;">1234567890</span></div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Spécifications">Spécifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Spécification</th>
+ <th scope="col">État</th>
+ <th scope="col">Commentaires</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('CSS4 UI', '#text-overflow', 'text-overflow')}}</td>
+ <td>{{Spec2('CSS4 UI')}}</td>
+ <td>Ajout des valeurs <code>&lt;string&gt;</code> et <code>fade</code> et de la fonction <code>fade()</code>.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('CSS3 Overflow', '#text-overflow', 'text-overflow')}}</td>
+ <td>{{Spec2('CSS3 Overflow')}}</td>
+ <td>Définition initiale.</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Une version précédente de cette interface avait atteint le statut de <em>Candidate Recommendation</em>. Certaines fonctionnalités devaient être retirées et n'étaient pas listées parmi les fonctionnalités à risque, la spécification a donc été déchue au niveau <em>Working Draft</em>. Cela explique pourquoi les navigateurs ont implémenté cette propriété sans préfixe bien qu'elle ne soit pas une CR.</p>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<div class="hidden">Ce tableau de compatibilité a été généré à partir de données structurées. Si vous souhaitez contribuer à ces données, n'hésitez pas à envoyer une <em>pull request</em> sur <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>.</div>
+
+<p>{{Compat("css.properties.text-overflow")}}</p>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li>{{cssxref("overflow")}}</li>
+ <li>{{cssxref("white-space")}}</li>
+</ul>