Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.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
Asp.net 限制html中的列宽_Asp.net_Html_Css - Fatal编程技术网

Asp.net 限制html中的列宽

Asp.net 限制html中的列宽,asp.net,html,css,Asp.net,Html,Css,我建立了下表: <table id="viewConfigurationTable" style="width:700px"> <tr> <td style="width:100px">Id</td> <td style="width:100px">Name</td> <td style="width:200px">Status</td>

我建立了下表:

    <table id="viewConfigurationTable" style="width:700px">
    <tr>
        <td style="width:100px">Id</td>
        <td style="width:100px">Name</td>
        <td style="width:200px">Status</td>
        <td style="width:300px">Ctids</td>
        <td style="width:300px">CreationDate</td>
    </tr>

    <% foreach (var config in Model.AliveConfigurations)
       {
    %>
    <tr>
        <td><%=config.Id%></td>
        <td><%=config.Name%></td>
        <td><%=config.Status%></td>
        <td><%=config.Ctids%></td>
        <td><%=config.CreationDate%></td>

    </tr>
    <%
        }
    %>
</table>

身份证件
名称
地位
CTID
创建日期
然而,
CTID
列有时会变得很宽


如何解决这个问题?

从我的观点来看,表格宽度是“不可用的”,您可以尝试将其设置为div

但如果您确实需要固定表格,请更改
TD
的宽度以匹配表格宽度,将
table layout:fixed
作为样式添加到表格中,并将
TD
设置为断开单词:
word wrap:break word


在我看来,表格宽度是“不可用的”,您可以尝试将其设置为
div

但如果您确实需要固定表格,请更改
TD
的宽度以匹配表格宽度,将
table layout:fixed
作为样式添加到表格中,并将
TD
设置为断开单词:
word wrap:break word

试试这个:

   <style type="text/css">
    table {
      width: 25%;//use this value for the table size compared to the screen size.
    }
    table td {
      width:auto;
      border: 1px solid red;
    }
  </style>

    <table id="viewConfigurationTable">
        <tr>
            <td>Id</td>
            <td>Name</td>
            <td>Status</td>
            <td>Ctids</td>
            <td>CreationDate</td>
        </tr>

        <% foreach (var config in Model.AliveConfigurations)
           {
        %>
        <tr>
            <td><%=config.Id%></td>
            <td><%=config.Name%></td>
            <td><%=config.Status%></td>
            <td><%=config.Ctids%></td>
            <td><%=config.CreationDate%></td>

        </tr>
        <%
            }
        %>
    </table>

桌子{
宽度:25%;//将此值用于与屏幕大小相比的表格大小。
}
表td{
宽度:自动;
边框:1px纯红;
}
身份证件
名称
地位
CTID
创建日期

试试这个:

   <style type="text/css">
    table {
      width: 25%;//use this value for the table size compared to the screen size.
    }
    table td {
      width:auto;
      border: 1px solid red;
    }
  </style>

    <table id="viewConfigurationTable">
        <tr>
            <td>Id</td>
            <td>Name</td>
            <td>Status</td>
            <td>Ctids</td>
            <td>CreationDate</td>
        </tr>

        <% foreach (var config in Model.AliveConfigurations)
           {
        %>
        <tr>
            <td><%=config.Id%></td>
            <td><%=config.Name%></td>
            <td><%=config.Status%></td>
            <td><%=config.Ctids%></td>
            <td><%=config.CreationDate%></td>

        </tr>
        <%
            }
        %>
    </table>

桌子{
宽度:25%;//将此值用于与屏幕大小相比的表格大小。
}
表td{
宽度:自动;
边框:1px纯红;
}
身份证件
名称
地位
CTID
创建日期

查看

FYI:您的表宽度设置为700px,但所有列的总宽度为1000px。我认为您还需要为其他行的所有tds提供宽度。(foreach循环中的一行)…您是否尝试过最大宽度:和换行:断开单词;请参考:您的表宽度设置为700px,但所有列的总宽度为1000px。我认为您还需要为其他行的所有tds提供宽度。(foreach循环中的一行)…您是否尝试过最大宽度:和换行:断开单词;参考