开发者

Make cell stay 10% wide

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.


This might do the trick:

#your_table {
  table-layout: fixed;
}

Tables can (should, as it's up to browsers to implement this) have two types of layouts:

  1. table-layout: fixed: This is the "stupid" table layout. The table doesn't care about its contents and just resizes carelessly.
  2. 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


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.

table.myClass{
    width: 300px;
}

table.myClass td.myOtherClass{
    width: 10%;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜