Set the width of the table to be fixed so that it does not change with the text

Set the width of the table to be fixed so that it does not change with the text
After setting the table width in the page to width="600px", the width is still not fixed. The text does not wrap when it is too long, which deforms the table.

Solution:

1. Table sets width, both absolute and relative width are acceptable

table-layout:fixed;
With this property set, all remaining td's will have the same width.

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

Solution:

Add style="word-wrap:break-word;" to the td to wrap the text. If you don't want to wrap the text, you can hide the content that exceeds the limit and replace it with an ellipsis:

Add above td

Copy code
The code is as follows:

overflow:hidden;
white-space:nowrap;

text-overflow:ellipsis; (currently only tested in IE8)
Recommended method (2013-11-14 by Zhang Lei) Use div to control the content of td

Add in TD

(1) Text will be automatically hidden if it exceeds the width and height

Copy code
The code is as follows:

<div style="width:100px;height:25px;overflow-x:hidden;overflow-y:hidden;">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>

(2) Set the TD width to automatically wrap when it exceeds the length

Copy code
The code is as follows:

<td><div style="width:100px;word-wrap:break-word;" >aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
</td>

<<:  Explore how an LED can get you started with the Linux kernel

>>:  Introduction to document.activeELement focus element in JavaScript

Recommend

12 Javascript table controls (DataGrid) are sorted out

When the DataSource property of a DataGrid control...

Detailed steps for debugging VUE projects in IDEA

To debug js code, you need to write debugger in t...

Div adaptive height automatically fills the remaining height

Scenario 1: Html: <div class="outer"...

Master the CSS property display:flow-root declaration in one article

byzhangxinxu from https://www.zhangxinxu.com/word...

Application example tutorial of key in Vue page rendering

introduction During the front-end project develop...

How to implement a password strength detector in react

Table of contents Preface use Component Writing D...

How to install Linux flash

How to install flash in Linux 1. Visit the flash ...

Do you know the common MySQL design errors?

Thanks to the development of the Internet, we can...

How to restore a database and a table from a MySQL full database backup

In the official MySQL dump tool, how can I restor...

How to understand Vue's simple state management store mode

Table of contents Overview 1. Define store.js 2. ...

How to install Odoo12 development environment on Windows 10

Preface Since many friends say they don’t have Ma...

Use overflow: hidden to disable page scrollbars

Copy code The code is as follows: html { overflow...

How to display div on object without being blocked by object animation

Today I made a menu button. When you move the mous...

Ubuntu 16.04 mysql5.7.17 open remote port 3306

Enable remote access to MySQL By default, MySQL u...