Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Css更改asp tablecell,而不调整其大小_C#_Css_Asp.net - Fatal编程技术网

C# Css更改asp tablecell,而不调整其大小

C# Css更改asp tablecell,而不调整其大小,c#,css,asp.net,C#,Css,Asp.net,我在代码隐藏中使用C#创建了一个tablecell,并向单元格内的标签添加了一个CSS类来旋转它: .vertical {color:#333; filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); -webkit-transform:rotate(270deg); -moz-transform:rotate(270deg)

我在代码隐藏中使用C#创建了一个tablecell,并向单元格内的标签添加了一个CSS类来旋转它:

.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样式更改我的表格单元格的大小后,是否可以使我的表格重新调整大小?

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

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

一些东西
一些其他的东西sljk fkas jd
...
​
然后使用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));    
});
$.fn.textWidth=函数(){
var html_org=$(this.html();
var html_calc=''+html_org+'';
$(this).html(html\u calc);
var width=$(this.find('span:first').width();
$(this.html(html_org);
返回宽度;
};
$(函数(){
var someLabelSize=$(“#someLabel”).textWidth();
$(“#someLabel”).css(“高度”,“someLabelSize+5”);
});

只需更改选择器以反映您的需要。

我们需要更多代码。显示您的html或编辑此小提琴。你的小提琴在整张桌子上都是垂直的。OP指定它只在单元格内的标签上。不幸的是,旋转的元素仍然占据空间,好像它没有旋转一样。我想你可能需要自己用填充来解释这一点。不幸的是,我真的想调整表的大小以适应新元素@JamesMontagne感谢您的评论,但我的问题是,表的宽度需要缩小,高度需要增加(由于内容是动态创建的,所以数量未知)。迈克尔:你知道,如果我在整张桌子上使用旋转css类,我可能会有一些工作要做。。。我将看看这会如何影响我的其他表元素。谢谢