让单元格保持 10% 宽
我有一个 10% 宽的单元格,里面有几个单词。当您缩小窗口大小时,大小会不断变小,直到与内部文本的长度匹配,然后停止缩小。我希望它保持在 10% 的宽度。我该怎么做?
抱歉,不能选择使用 div。
I have a cell that is 10% wide with a couple words in it. When you shrink the window size, the size keeps getting smaller until it matches the length of the text inside and then it stops shrinking. I want it to stay at an exact 10% wide. How do I do this?
Sorry, working with divs is not an option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能会起作用:
表格(应该由浏览器来实现)有两种类型的布局:
table-layout:fixed
:这是“愚蠢”的表格布局。该表不关心其内容,只是随意调整大小。table-layout: auto
:这是“智能”表格布局。表关心其内容,并在达到单元格的最小宽度和高度后停止调整单元格大小。这是默认的表行为。谢谢 W3C:http://www.w3.org/TR /CSS2/tables.html#propdef-table-layout
This might do the trick:
Tables can (should, as it's up to browsers to implement this) have two types of layouts:
table-layout: fixed
: This is the "stupid" table layout. The table doesn't care about its contents and just resizes carelessly.table-layout: auto
: This is the "smart" table layout. The table cares about it's contents and stops resizing cells once the minimum width and height of a cell is reached. This is default table behavior.Thank you W3C: http://www.w3.org/TR/CSS2/tables.html#propdef-table-layout
看来您真正想要的是设定宽度。如果您说表格必须为 300px,则可以指定单元格始终为 30px。相对规模是导致问题的原因。
It looks like what you really want is a set width. If you say that the table has to be 300px, you can specify that the cell is always 30px. The relative scale is what's causing the problem.