使用 CSS 在元素内部禁用文本换行


若要禁用元素内部的文本换行,请使用 white-space 属性。您可以尝试运行以下代码来实现 white-space 属性

示例

在线演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         p {
            white-space: nowrap;
         }
      </style>
   </head>
   <body>
      <p>
         This is demo text. This is demo text.
         This is demo text. This is demo text.
         This is demo text. This is demo text.
         This is some text. This is demo text.
      </p>
   </body>
</html>

更新时间:2020 年 6 月 21 日

492 次浏览

开启您的 职业生涯

完成课程并获得认证

开始学习
广告
© . All rights reserved.