2012-10-02 25 views
0

我使用C#在我后面的代码做一个TableCell的,我添加一个CSS类的标签的单元格内旋转它:CSS支持的变化ASP TableCell的,而不调整其大小

.vertical {color:#333; 
       filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); 
       -webkit-transform:rotate(270deg); 
       -moz-transform:rotate(270deg); 
       -o-transform: rotate(270deg); 
       white-space:nowrap; 
       display:block; 
       } 

的问题是,经过我旋转我的标签,我的表格单元格(和表格)没有调整大小以适应新文本。有没有一种方法使用CSS或我可以用来自动调整表格大小以适应新内容的属性?

我很感激任何帮助。

---编辑--- 所以在玩了一些CSS类之后,我意识到了我的问题的根源。基本上,我应用CSS更改后 - 我的表不调整大小。它们仍然像内容未被修改一样大小。

在CSS样式更改我的表格大小后,是否可以使表格重新大小?

+0

我们将需要更多的代码。向我们显示您的html或编辑这个小提琴。 http://jsfiddle.net/UfeWQ/ – davehale23

+1

你的小提琴在整个桌子上有垂直类。 OP指定它只在单元格内的标签上。 –

+0

不幸的是旋转的元素仍然占用空间,就好像它没有旋转一样。我想你可能需要用填充来解决这个问题。 –

回答

0

您需要计算标签的新的height,然后将其包含的元素设置为该高度。 This fiddle就是我所说的。

<table> 
    <tr> 
     <td id="someLabel" class="vertical">some stuff</td> 
     <td>some other stuff sljk fkas jd</td> 
    </tr>  
    ... 
</table>​ 

,然后使用jQuery

$.fn.textWidth = function() { 
    var html_org = $(this).html(); 
    var html_calc = '<span>' + html_org + '</span>'; 
    $(this).html(html_calc); 
    var width = $(this).find('span:first').width(); 
    $(this).html(html_org); 
    return width; 
}; 

$(function(){ 
    var someLabelSize = $("#someLabel").textWidth(); 
    $("#someLabel").css("height", (someLabelSize + 5));  
}); 

只要改变选择,以满足您的需求。

相关问题