我正在使用sencha touch xTemplate。众所周知,sencha touch xtemplate只是html。我想在td中使用div,原因如下:
我的代码是这样的:
......
......
'<td>' +
'<div style = "overflow:hidden; text-overflow:ellipsis; width:80%; max-width: 100%;">'+
'Here is the text to cut'+
'</div>'+
'</td>' +
......
......
这是一个问题: 当我把div放在td里面时,td会扩展。当我将max-width设置为100px之类的数字时,它不会扩展。但我不想将宽度设置为固定数字。如何让div和td不扩展?
我还是这个领域的大三学生。所以请帮帮我!
width:80%;max-width:100%
毫无意义。如果宽度是80%
,它永远不会达到你为它设置的最大值。 width
或max-width
中的至少一个应该是绝对值,而不是百分比。
就<td>
扩展而言,您可以尝试在表格单元格上设置宽度。如果这不起作用,您还可以将table-layout:fixed
添加到表格的样式中。