确定如何使用 CSS 向用户发出有关未显示的溢出内容的信号


text-overflow 属性用于确定如何使用 CSS 向用户发出有关未显示的溢出内容的信号。

示例

你可以尝试运行以下代码在 CSS 中实现 text-overflow 属性

在线演示

<html>
   <head>
      <style>
         p.text1 {
            white-space: nowrap;
            width: 200px;
            border: 1px solid #000000;
            overflow: hidden;
            text-overflow: clip;
         }
         p.text2 {
            white-space: nowrap;
            width: 200px;
            border: 1px solid #000000;
            overflow: hidden;
            text-overflow: ellipsis;
         }
      </style>
   </head>
   <body>
      <b>Original Text:</b>
      <p>Tutorials Point originated from the idea that there exists a class of
      readers who respond better to online content and prefer to learn new skills at
      their own pace from the comforts of their drawing rooms.</p>
      <b>Text overflow:clip:</b>
     
      <p class = "text1">Tutorials Point originated from the idea that there exists
      a class of readers who respond better to online content and prefer to learn
      new skills at their own pace from the comforts of their drawing rooms.</p>
      <b>Text overflow:ellipsis</b>
     
      <p class = "text2">Tutorials Point originated from the idea that there exists
      a class of readers who respond better to online content and prefer to learn
      new skills at their own pace from the comforts of their drawing rooms.</p>
   </body>
</html>

输出

最新更新时间:2020 年 6 月 20 日

83 次浏览

开启你的 职业生涯

完成课程以获得认证

开始学习
广告