recherche

Maison  >  Questions et réponses  >  le corps du texte

Comment tronquer le texte de la balise d'ancrage dans un tableau HTML

<p>J'essaie de tronquer le texte dans le texte d'ancrage d'un élément. J'ai ajouté <code>overflow: Hidden; text-overflow: ellipsis;</code> dans le style de ma balise d'ancrage, mais elle s'enroule toujours.这里有一些可以复现的HTML:</p> <p><br /></p> <pre class="brush:html;toolbar:false;"> <html lang="fr" xmlns="http://www.w3.org/1999/xhtml"> <tête> <titre>Test Test 123</titre> ≪/tête> <corps> <div style="largeur : 100 %; rembourrage supérieur : 1px;"> <div class="contenu" style="largeur : 512 px ; flex-shrink : 0 ; marge-gauche : auto ; marge-droite : auto ; affichage : bloc ;"> <div class="contents-body" style="affichage : bloc ; largeur : 512px;"> <table style="width:50%; border-collapse : réduire; marge gauche : auto; marge droite : auto;"> <corps> <tr style="justify-content:center;align-items:center;gap:56px;color:#848585"> <th style="padding-top:8px;padding-bottom: 10px; font-style:normal;font-weight:500;line-height:16px;letter-spacing:0.1px;text-align:left;width :25%">Colonne A</th> <th style="padding-top:8px;padding-bottom: 10px; font-style:normal;font-weight:500;line-height:16px;letter-spacing:0.1px;text-align:left;width :25%">Colonne B</th> ≪/tr> <tr> <td rowspan="3" style = "largeur : 25 % ; padding-top : 8px ; padding-bottom : 8px ; text-align : left ; font-size : 14px ; espacement des lettres : 0,1 px;"> Entrée A</td> <td style="padding-top:8px; padding-bottom:8px; text-align:left;font-size:14px;font-style : normal;font-weight:400;line-height : 16px;letter- espacement:0,1px;text-decoration-line:underline;"> <a style="color:#E25323; débordement : caché ; débordement de texte : points de suspension ; largeur : 50 px ;" href="https://localhost">ABC123ABC-ABC123ABC`</a> </td> ≪/tr> </tcorps> </tableau> </div> </div> </div> </corps> </html></pre> <p><br /></p> <p> Cela ne semble pas aimer la largeur de 50 px sur le texte de la balise d'ancrage, je pense que c'est la largeur de la colonne qui le dérange. </p>
P粉547170972P粉547170972546 Il y a quelques jours554

répondre à tous(1)je répondrai

  • P粉099145710

    P粉0991457102023-08-17 00:29:51

    Si vous ne souhaitez pas boucler la ligne, vous pouvez ajouter white-space:nowrap;
    Si vous souhaitez définir width,设置为 50px,而不是 50 px (aucun espace autorisé) ; Si tu veux
    width 生效,将你的 <a> 设置为块级元素,例如使用 display:inline-block

    Voici le code :

    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
      <title>Test Test 123</title>
    </head>
    
    <body>
      <div style="width: 100%; padding-top: 1px;">
        <div class="contents" style="width: 512px; flex-shrink: 0; margin-left: auto; margin-right: auto; display: block;">
          <div class="contents-body" style="display: block; width: 512px;">
            <table style="width:50%; border-collapse: collapse; margin-left: auto; margin-right: auto;">
              <tbody>
                <tr style="justify-content:center;align-items:center;gap:56px;color:#848585">
                  <th style="padding-top:8px;padding-bottom: 10px; font-style:normal;font-weight:500;line-height:16px;letter-spacing:0.1px;text-align:left;width:25%">Column A</th>
                  <th style="padding-top:8px;padding-bottom: 10px; font-style:normal;font-weight:500;line-height:16px;letter-spacing:0.1px;text-align:left;width:25%">Column B</th>
                </tr>
                <tr>
                  <td rowspan="3" style="width:25%; padding-top:8px; padding-bottom:8px; text-align:left;font-size:14px;font-style:normal;font-weight:500;line-height:16px; letter-spacing:0.1px;">Entry A</td>
                  <td style="padding-top:8px; padding-bottom:8px; text-align:left;font-size:14px;font-style: normal;font-weight:400;line-height: 16px;letter-spacing:0.1px;text-decoration-line:underline;">
                    <a style="color:#E25323; overflow: hidden; text-overflow: ellipsis; display:inline-block; width: 50px; white-space:nowrap" href="https://localhost">ABC123ABC-ABC123ABC`</a>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </body>
    
    </html>

    répondre
    0
  • Annulerrépondre