2012-05-24 123 views

回答

4

定义面板像这里面的容器:

<asp:Panel CssClass="CustomWidth" ID="MyPanel" runat="server"> </asp:Panel> 

然后链接到设置下列外部CSS样式表:

.CustomWidth{  width: 25%; } 
3

您可以使用jQuery为:

假设Panel1是你的面板的ID,并且,要根据工作的各个内容容器为Container1

var dWidth = $('#Container1').width(); 
$('#Panel1').width(dWidth * 0.25); 

将设置Panel1宽度为您使用的容器的25%。

只是决定你想一起工作(可能是一个div或任何类似的,你不告诉我们你的代码)

-1

我真的不明白你的问题,但它看起来像JavaScript乔布, 例如:

var Element_Id = document.getElementById("Elem_Id"); // Element Id 
var curr_Element_Width = parseInt(Element_Id.clientWidth); // parseInt is taking down our "px" string at the width.... look: 
var curr_Element_Id_Width = 100px we need INT only! 
we only need the number 100 so after parseInt its now 100 and not 100px we can't work with string's and that is the reson we doing that, 

然后你可以使用函数像这样的......

function addWidth() { 
    Element_Id.style.width = (curr_Element_Width + 100) + 'px'; // after we change the width we add the "px" string again 
} 

在这里,我们Px的工作,但你可以用%希望它会帮助你,有一个相同美好的一天。

相关问题