TD内的DIV是一个坏主意吗? [英] Is a DIV inside a TD a bad idea?
问题描述
看来我听到/读过某个< div>
在< td>
是一个禁忌。并不是说它不起作用,只是基于它们的显示类型而不是真正兼容的东西。找不到任何证据来支持我的预感,所以我可能完全错误。 使用 div
显示
如果您使用 div
在 td
中,你会遇到一种情况,可能很难预测元素的大小。 div的默认值是从它的父元素中确定它的宽度,表格单元格的默认值是根据其内容的大小确定它的大小。
有关如何确定 It seems like I heard/read somewhere that a Using a If you use a The rules for how a 这篇关于TD内的DIV是一个坏主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! div
大小的规则在标准中有明确定义,但<div>
inside of a <td>
was a no-no. Not that it won't work, just something about them not being really compatible based on their display type. Can't find any evidence to back up my hunch, so I may be totally wrong. div
instide a td
is not worse than any other way of using tables for layout. (Some people never use tables for layout though, and I happen to be one of them.)div
in a td
you will however get in a situation where it might be hard to predict how the elements will be sized. The default for a div is to determine its width from its parent, and the default for a table cell is to determine its size depending on the size of its content.div
should be sized is well defined in the standards, but the rules for how a td
should be sized is not as well defined, so different browsers use slightly different algorithms.