简体   繁体   中英

How to make table not be resized?

How can I prevent a table from being resized?

I change the content of the table with Ajax so I want the table to be fixed, not resized automatically as the content changes.

How can I do that?

You can use the width attribute on your table cells to fix their width.

You only have to use it on cells in the first row of your table; the browser will keep those widths for all the cells in the respective columns.

Alternatively, you can add a class attribute to your table cells, and set their width i your stylesheet. If so, you might want to also apply table-layout: fixed to your <table> tag.

Do it with CSS:

table td {
  width: [somevalue];
  height: [somevalue];
}

That way the cells will remain the same size even when the content is changed.

I have this suggestion please check it out. I'm not that good in css but I just thought that maybe a work-around would help. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM