css自動換行

來源:互聯網
上載者:User
方法一:首先固定表格寬度,即給表格一個寬度值(數值,非百分比)

方法二:強制不換行

  div{//white-space:不換行;normal 預設;nowrap強制在同一行內顯示所有文本,直到文本結束或者遭遇 br 對象white-space:nowrap; }

方法三:自動換行

  div{ word-wrap: break-word; //word-break設定強行換行;normal 亞洲語言和非亞洲語言的文本規則,允許在字內換行word-break: normal; }

方法四:強制英文單詞斷行

  div{word-break:break-all;}

註:

在CSS中定義如下句子,可防止網頁“被撐開”了:

  table{table-layout: fixed;}td(word-break: break-all; word-wrap:break-word;)

防止表格/層被“撐開”,同時保證分行時單個英文單詞不會被拆開:

  table { table-layout: fixed;word-wrap:break-word;}

  div { word-wrap:break-word;}

  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.