CSS shows that the table content exceeds the ellipsis used for display-it is indeed available, but it turns out that ~

Source: Internet
Author: User
 
Table{Table-Layout:Fixed;}TD{White-space:Nowrap;Overflow:Hidden;Text-Overflow:Ellipsis;}

 

Principle:

This method is used to solveTable CellThe appearance of too much content mainly involves four CSS styles:

1.Table-layout: fixedBecause the default value of table-layout is auto, that is, the width and height of a table depend on the quantity of its content. If the volume of the content cannot be estimated, the final form of the table cannot be guaranteed, fixed.(Note: This style is critical)

2.White-space: nowrapTo ensure that no line breaks are automatically generated regardless of the number of text content in the cell (TD). In this case, the excess content will break through the cell horizontally.

3.Overflow: hiddenHide the part that exceeds the cell.

4.Text-overflow: ellipsisReplace the hidden part with a ellipsis.

 

:

Source code :
 <!  Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"  >  <  Html  Xmlns  = "Http://www.w3.org/1999/xhtml"  >  <  Head  >      <  Style  Type  = "Text/CSS"  >  Table  {  Table-Layout  :  Fixed ;  Width  :  100%  ;          }  TD  {  White-space  :  Nowrap  ;  Overflow  :  Hidden  ;  Text-Overflow  :  Ellipsis  ;  Background-color  :  # Ccc  ;          }      </  Style  > </  Head  >  <  Body  >      <  Table  >          <  Thead  >              <  Th  >  First column  </  Th  >              <  Th  >  Column 2  </  Th  >          </  Thead  >          < Tbody  >              <  Tr  >                  <  TD  >                      <  Span  > Ultra-long content, ultra-long Content ultra-long content ultra-long Content </  Span  > <  Span  > Ultra-long content, ultra-long Content ultra-long content ultra-long Content </  Span  >                  </  TD  >                  <  TD >  Ultra-long content, ultra-long Content ultra-long content ultra-long Content  </  TD  >              </  Tr  >          </  Tbody  >      </  Table  >  </  Body  >  </  Html  > 

 

Compatibility:

Internet Explorer 6, 7, 8, 9 and later

Latest firefox version

Latest chrome version

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.