How do I set the width of a table to not change with text?

Source: Internet
Author: User


Table width of the page set width= "600px", the width is still not fixed, the text is too long after the line, the table has been deformed.



Solution:



1.table set width, absolute width and relative can

table-layout:fixed;
This property is set, and all the other TD are the same width.


After this operation, the table is fixed width, but if the article inside is very long, the text will overwrite

Solution:



In the TD plus Style= "Word-wrap:break-word", if you do not want to wrap, you can set the excess content as hidden, and use ellipses instead:

Add the TD above

Overflow:hidden;
White-space:nowrap;


Text-overflow:ellipsis (currently only in IE8 test pass)
Recommended method (2013-11-14 by Zhang Lei) using Div to control the content of TD

Add in TD

(1) More than width and height text will be hidden automatically
<div style= "Width:100px;height:25px;overflow-x:hidden;overflow-y:hidden;" >aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>

(2) Set the TD's width over the length of automatic line wrap
<td><div style= "Width:100px;word-wrap:break-word;" > Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
</td>

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.