C# 如何设置表格列的宽度限制?

C# 如何设置表格列的宽度限制?,c#,css,asp.net,webforms,html-table,C#,Css,Asp.net,Webforms,Html Table,我有一个包含数据的表,在第一个字段中有可翻译的标签 我希望能够在标签列中设置一个宽度,但是如果有人翻译标签,并且文本较长,则可以将列扩展到给定的点 标签列要求示例: Width: 200px; Expandable: true; Max Expanding: 300px; 注意:我特别询问如何启用此功能,但它在扩展时必须具有最大宽度 <table id="tblCustTypes" class="tblTop"> <tr>

我有一个包含数据的表,在第一个字段中有可翻译的标签

我希望能够在标签列中设置一个宽度,但是如果有人翻译标签,并且文本较长,则可以将列扩展到给定的点

标签列要求示例:

Width: 200px;
Expandable: true;
Max Expanding: 300px; 
注意:我特别询问如何启用此功能,但它在扩展时必须具有最大宽度

    <table id="tblCustTypes" class="tblTop">
        <tr>
            <td class="auto-style1">
                <asp:Label ID="lblCustType" runat="server" Text="Cust Type"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtCustomerType" runat="server" Width="20%" class="autosuggest" CssClass="autosuggest" OnChange="onSave();" OnTextChanged="txtCustomerType_TextChanged" AutoPostBack="True"></asp:TextBox>
                <asp:Label ID="lblTempCustType" runat="server" Visible="false"></asp:Label>

            </td>
        </tr>
        <tr>
            <td class="auto-style1">
                <asp:Label ID="lblDescription" runat="server" Text="Description"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtDescription" runat="server" Width="35%"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="auto-style1">
                <asp:Label ID="lblApplyVAT" runat="server" Text="Apply VAT"></asp:Label>
            </td>
            <td>
                <asp:RadioButtonList ID="rblApplyVAT" runat="server" RepeatDirection="Horizontal">
                    <asp:ListItem Selected="True" Value="1">Yes</asp:ListItem>
                    <asp:ListItem Value="0">No</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td class="auto-style1">
                <asp:Label ID="lblProduceInvoices" runat="server" Text="Produce Invoices"></asp:Label>
            </td>
            <td>
                <asp:RadioButtonList ID="rblProduceInvoices" runat="server" RepeatDirection="Horizontal">
                    <asp:ListItem Selected="True" Value="1">Yes</asp:ListItem>
                    <asp:ListItem Value="0">No</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td class="auto-style1">
                <asp:Label ID="lblPurchaseSale" runat="server" Text="Purchase/Sale"></asp:Label>
            </td>
            <td>
                <asp:RadioButtonList ID="rblPurchaseSale" runat="server" RepeatDirection="Horizontal">
                    <asp:ListItem Value="P">Purchase</asp:ListItem>
                    <asp:ListItem Selected="True" Value="S">Sale</asp:ListItem>
                </asp:RadioButtonList>
            </td>
        </tr>
        <tr>
            <td class="auto-style1">
                <asp:Label ID="lblTerms" runat="server" Text="Terms (Days)"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtTerms" runat="server" Width="5%"></asp:TextBox></td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="lblLastUpdated" runat="server" Text="Last Updated"></asp:Label>
            </td>
            <td>
                <asp:Label ID="lblLastUpdatedVal" runat="server" Text=""></asp:Label>
            </td>
        </tr>
    </table>

对
不
对
不
购买
特价

注释提供了解决方案。你用的是什么浏览器?
minwidth
属性与一些旧浏览器(包括IE 8)不兼容

我发现把它放在我的.aspx文件(或相关的内容控制)中就成功了

<style>
    .tblTop > tbody > tr >  td { 
        min-width:50px;
        max-width: 100px;
        border: 1px solid black;
    }
</style>


<table class="tblTop">
    <tr>
        <td>Hello</td>
        <td>Goodbye</td>
    </tr>
    <tr>
        <td>Some very long string that will extend to the maximum width that I set and force the words to wrap around.</td>
        <td>Goodbye</td>
    </tr>
</table>

这些意见提供了解决办法。你用的是什么浏览器?
minwidth
属性与一些旧浏览器(包括IE 8)不兼容

我发现把它放在我的.aspx文件(或相关的内容控制)中就成功了

<style>
    .tblTop > tbody > tr >  td { 
        min-width:50px;
        max-width: 100px;
        border: 1px solid black;
    }
</style>


<table class="tblTop">
    <tr>
        <td>Hello</td>
        <td>Goodbye</td>
    </tr>
    <tr>
        <td>Some very long string that will extend to the maximum width that I set and force the words to wrap around.</td>
        <td>Goodbye</td>
    </tr>
</table>

这些意见提供了解决办法。你用的是什么浏览器?
minwidth
属性与一些旧浏览器(包括IE 8)不兼容

我发现把它放在我的.aspx文件(或相关的内容控制)中就成功了

<style>
    .tblTop > tbody > tr >  td { 
        min-width:50px;
        max-width: 100px;
        border: 1px solid black;
    }
</style>


<table class="tblTop">
    <tr>
        <td>Hello</td>
        <td>Goodbye</td>
    </tr>
    <tr>
        <td>Some very long string that will extend to the maximum width that I set and force the words to wrap around.</td>
        <td>Goodbye</td>
    </tr>
</table>

这些意见提供了解决办法。你用的是什么浏览器?
minwidth
属性与一些旧浏览器(包括IE 8)不兼容

我发现把它放在我的.aspx文件(或相关的内容控制)中就成功了

<style>
    .tblTop > tbody > tr >  td { 
        min-width:50px;
        max-width: 100px;
        border: 1px solid black;
    }
</style>


<table class="tblTop">
    <tr>
        <td>Hello</td>
        <td>Goodbye</td>
    </tr>
    <tr>
        <td>Some very long string that will extend to the maximum width that I set and force the words to wrap around.</td>
        <td>Goodbye</td>
    </tr>
</table>

通常,要在表格中强制使用
宽度
,请使用
表格布局:固定上的解释

它也应该适用于最大宽度:

最大宽度为80px的基本CSS:

table {
    table-layout:fixed;
}

table tr :first-child {
    max-width:80px;
}

通常,要在表格中强制使用
宽度
,请使用
表格布局:固定上的解释

它也应该适用于最大宽度:

最大宽度为80px的基本CSS:

table {
    table-layout:fixed;
}

table tr :first-child {
    max-width:80px;
}

通常,要在表格中强制使用
宽度
,请使用
表格布局:固定上的解释

它也应该适用于最大宽度:

最大宽度为80px的基本CSS:

table {
    table-layout:fixed;
}

table tr :first-child {
    max-width:80px;
}

通常,要在表格中强制使用
宽度
,请使用
表格布局:固定上的解释

它也应该适用于最大宽度:

最大宽度为80px的基本CSS:

table {
    table-layout:fixed;
}

table tr :first-child {
    max-width:80px;
}


您可能想考虑使用<代码>最小宽度宽度>代码>。我尝试了最小宽度,但没有任何差别。在我看来,列需要自动扩展,但有一个限制。这可能吗?请注意,
minwidth
是CSS属性,而不是您上面使用的ASP.net属性。上面的示例不是真正的代码,这只是我需要的一个例子:“JimMSDNYou需要一个代码< min宽度>代码>和<代码>最大宽度的组合。您可能需要考虑使用<代码>最小宽度宽度< /代码>。我尝试了最小宽度,但没有任何差别。在我看来,列需要自动扩展,但有一个限制。这可能吗?请注意,
minwidth
是CSS属性,而不是您上面使用的ASP.net属性。上面的示例不是真正的代码,这只是我需要的一个例子:“JimMSDNYou需要一个代码< min宽度>代码>和<代码>最大宽度的组合。您可能需要考虑使用<代码>最小宽度宽度< /代码>。我尝试了最小宽度,但没有任何差别。在我看来,列需要自动扩展,但有一个限制。这可能吗?请注意,
minwidth
是CSS属性,而不是您上面使用的ASP.net属性。上面的示例不是真正的代码,这只是我需要的一个例子:“JimMSDNYou需要一个代码< min宽度>代码>和<代码>最大宽度的组合。您可能需要考虑使用<代码>最小宽度宽度< /代码>。我尝试了最小宽度,但没有任何差别。在我看来,列需要自动扩展,但有一个限制。这可能吗?请注意,
minwidth
是一个CSS属性,而不是您上面使用的ASP.net属性。上面的示例不是真正的代码,它只是我需要@jimmsdn的一个示例。您需要将
minwidth
max width
结合起来。