问题描述
.expandingTextarea在表格内不起作用涉及在 $('td')的表格单元格上使用css('max-width','0px')$ c $
An answer posted to jQuery.expandingTextarea not working inside a table involves the use on a table-cell of $('td').css('max-width','0px')
.
此回答提供的解决方案(至少在Chrome中)不适用于此行。
The solution provided by this answer does not work (at least in Chrome) without this line.
我找不到任何有关。它有一个定义的行为吗?或者,这只是一个任意的副作用,发生在所需的行为?
I could not find any documentation on what max-width
of 0px
might do, particularly to a table cell. Is there a defined behaviour for it? Or is this just an arbitrary side-effect that happens to result in the desired behaviour?
虽然有一个答案的链接问题,我不愿意标记它正确基于未来可能改变的未定义或未记录的行为,所以我想更多地了解为什么 max-width:0px
有效。
Although there is an answer to the linked question, I am hesitant to mark it correct based on undefined or undocumented behaviour that may change in the future, so I would like to know more about why max-width: 0px
works.
干杯
推荐答案
table {
table-layout: fixed;
}
这会将单元格宽度固定为给定的值。因此,如果您对单元格执行 width:30%
,则不会根据其内容调整其大小,并会保持其设置宽度。
This fixes the cell widths to the value they are given. So if you do width: 30%
on the cells, they won't resize based on their content and will maintain their set widths.
如果只给一些单元格赋予 width
值,剩余的单元格将共享可用空间。使用此功能替代 max-width
。
If only some of the cells are given a width
value, the remaining cells will share the space available. Use this functionality as a replacement to max-width
.
使用
这篇关于max-width:0px是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!