我有一個動態創建的表格。有時它可能有兩列,有時可能有20列。如何讓動態表的寬度不增加?
我的問題是如果它已加載表的寬度增加。
如何修復?
<div class="rightXMLSubCategory">
<table id = "XMLtable">
<tr>
@foreach(var item in Model.Part.attributes){
foreach(var attr in item.attr_type){
<th>
@attr.name
</th>
}
}
</tr>
<tr>
@foreach(var item in Model.Part.attributes){
foreach(var attr in item.attr_type){
<td>
@foreach(var attrs in attr.attr_value){
@attrs
<br/>
}
</td>
}
}
</tr>
</table>
CSS:
.rightXMLSubCategory
{
text-align:left;
width: 710px;
padding-left: 230px;
}
#XMLtable
{
border-radius:4px;
border: 1px solid #004389;
}
#XMLtable th
{
border-left: 1px solid #0066B3;
border-right: 1px solid #0066B3;
border-bottom: 1px solid #0066B3;
padding:3px 3px 3px 3px;
color: white;
background-color: #004389;
}
#XMLtable td
{
border-left: 1px solid #0066B3;
border-right: 1px solid #0066B3;
border-bottom: 1px solid #0066B3;
padding:3px 3px 3px 3px;
color: white;
background-color: #0066B3;
}
表格填充:
<table id = "XMLtable">
<tr>
<th>
Product Type
</th>
<th>
Actuator Style
</th>
<th>
Button Color
</th>
<th>
Termination Type
</th>
<th>
Panel Thickness
</th>
<th>
Circuit Breaker Style
</th>
<th>
Current Rating
</th>
<th>
Operating Voltage, Max.
</th>
<th>
Series
</th>
<th>
Brand
</th>
</tr>
<tr>
<td>Circuit Breaker</td>
<td>Push to Reset</td>
<td>Red</td>
<td>6.35 [.250] Straight Quick Connect Tab</td>
<td>0.81 - 1.57</td>
<td>Fuseholder Type</td>
<td>9</td>
<td>32 VDC250 VAC</td>
<td>W28</td>
<td>Potter & Brumfield</td>
</tr>
</table>
如果我拿出br它仍然是太寬 – Beginner
如果你把所有的行都拿出來放在同一行上。這顯然不是你想要的,除非總是隻有一行。 但是取出'
'不是寬度解決方案的一部分,只是一個改進的想法 – ramsesoriginal