我正在尝试调整像这样的单元格:
margin:5px;
padding:1px;
border: solid 2px;
color:blue;
text-align:center;
position:relative;
max-width:50px;
单元格的边框遵循CSS设置,但实际单元格似乎从容器溢出到右侧。任何想法如何让细胞具有相同的容器宽度?我有点困惑,因为我认为<td>
标签实际上是单元格。
答案 0 :(得分:0)
我能够使用以下css格式化包含@ html.textbox和@ html.textboxfor的单元格并直接在视图中:
#allAttendanceGradeHead
{
border-collapse:collapse;
margin:1px;
padding:1px;
border: solid 2px #a8adfd;
color:Green;
max-width: 100px;
text-align:center;
}
#homeworkGradeCell
{
border-collapse:collapse;
margin:1px;
padding:1px;
border: solid 2px;
border-color: Fuchsia;
background-color:Yellow;
max-width:200px;
text-align:center;
}
在视图中:
<td id="homeworkGradeCell" style=" border-color:Lime">
@Html.TextBox("HomeworkGrade", "100", new { style = "width:60px; color:red; text-align: center" })
@if (@ViewBag.NumberErrorMessage != null)
{
<div id="numberRequiredMessage">
@ViewBag.NumberErrorMessage
</div>
}
</td>
这是@ html.textboxfor ...
#attendanceCodeCell
{
color:Maroon;
max-width:2px;
position:relative;
border: solid 2px #a8adfd;
}
And in the view:
<td id="attendanceCodeCell">
@Html.TextBoxFor(modelItem => item.attendanceCode, new { Value = "1",style =" width:12px; border-color:red"})
@Html.ValidationMessageFor(modelItem => item.attendanceCode)
</td>