網頁中防止表格被撐破的css代碼

來源:互聯網
上載者:User

按照網上大多數文章的說法,只要在CSS中加入:

代碼

table {

table-layout:fixed;

word-break:break-all;

word-wrap:break-word;

}

div {

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.