我有一個奇怪的情況,我有一個表,在每一行我有一個Ajax形式。 Form
不允許在tr
,但允許在td
。所以我必須將所有欄放在td
內,並手動匹配尺寸。問題在於HtmlHelpers(ASP.Net MVC Razor)添加的填充和邊距,導致內容不能在正確的標題列下對齊。Html CSS - 將樣式應用於類中的所有元素?
我需要寫一個css,在給定的類中遞歸地去除所有項目的邊距和填充。我怎樣才能做到這一點?
或者是否有更簡單的方法來強制對齊標題下的內容?
<table style="width: 100%">
<thead>
<tr>
<th style="width: 5%">Id</th>
<th style="width: 35%">Material</th>
<th style="width: 60%">Description</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.items){
<tr>
<td class="noMarginAndPadding" colspan="3">
@using (@Ajax.BeginForm()){
<span style="width: 5%">@Html.TextBoxFor(i => item.Id)</span>
<span style="width: 35%">@Html.TextBoxFor(i => item.Name)</span>
<span style="width: 60%">@Html.TextBoxFor(i => item.Description)</span>
}
</td>
</tr>
}
</tbody>
理論上,'td.noMarginAndPadding * {餘量:0;填充:0; }'應該這樣做。如果你可以使用相關的樣式表來http://jsfiddle.net你的客戶端表單,它會更容易一些。 – 2013-03-21 02:57:52
恐怕不行。我嘗試了同樣的事情。根據瀏覽器排序(class =「firefox」等),我有一個php腳本動態地爲html標籤分配一個類。這工作。另外,我把它放在我的CSS中:'.opera * {letter-spacing:.002em}',但那不起作用。 – 2013-03-21 03:09:33
添加子組合選擇器(>)有什麼區別嗎?即td.noMarginAndPadding> * {margin:0;填充:0; } – lukeocom 2013-03-21 03:18:14