こんにちわ!
ASP.NET MVC5(VisualStudio2017)でWeb勤務表を作っています。
基本的な質問になるかもしれませんが、テーブルでEditorForとDisplayForを横並びに表示したときに、高さがずれてしまいます。日付と曜日はstyle="margin-top:5px"で調整出来たんですが、DisplayForでどのように調整するのか分かりません。知っている方がいらっしゃいましたら教えてください。
あとDropdownlistの高さ調整と、大きさもEditorForと同じ大きさに変えたいのですが、出来たらこちらもアドバイスお願いします。
Bootstrap ver.3.0.0
ビュー:
@model Kintai_CS_.Models.KintaiModel @{ /**/ ViewBag.Title = "勤務表"; Layout = "~/Views/Shared/_Layout.cshtml"; Dictionary<int, SelectList> dictionary = (Dictionary<int, SelectList>)ViewBag.Situation; } @using (Html.BeginForm()) { @Html.AntiForgeryToken() <header id="header" class="header"> ・・・ </header> <body id="body" class="body"> ・・・ <table class="table"> <tr> <th> <nobr>日付</nobr> </th> <th> <nobr>曜日</nobr> </th> <th> <nobr><div align="center">始業時刻</div></nobr> </th> <th> <nobr><div align="center">終業時刻</div></nobr> </th> <th> <nobr><div align="center">休憩時間</div></nobr> </th> <th> <nobr>所定時間</nobr> </th> <th> <nobr>残業時間</nobr> </th> <th> <nobr><div align="center">勤怠状況</div></nobr> </th> <th> <nobr><div align="center">補助</div></nobr> </th> <th> <nobr><div align="center">備考</div></nobr> </th> </tr> @for (int i = 0; i < Model.Kintais.Count; i++) { int idx = i; <tr> @{ string week = Model.Kintais[idx].date.ToString("ddd"); if (week == "土") { <td><div style="color:blue;margin-top:5px" align="center">@(idx + 1)</div></td> <td><div style="color:blue;margin-top:5px" align="center">@week</div></td> } else if (week == "日") { <td><div style="color:red;margin-top:5px" align="center">@(idx + 1)</div></td> <td><div style="color:red;margin-top:5px" align="center">@week</div></td> } else { <td><div style="margin-top:5px" align="center">@(idx + 1)</div></td> <td><div style="margin-top:5px" align="center">@week</div></td> } } <td> @Html.EditorFor(model => model.Kintais[idx].open, new { htmlAttributes = new { @class = "form-control", style = "width:80px" } }) @Html.ValidationMessageFor(model => model.Kintais[idx].open, "", new { @class = "text-danger" }) </td> <td> @Html.EditorFor(model => model.Kintais[idx].close, new { htmlAttributes = new { @class = "form-control", style = "width:80px" } }) @Html.ValidationMessageFor(model => model.Kintais[idx].close, "", new { @class = "text-danger" }) </td> <td> @Html.EditorFor(model => model.Kintais[idx].rest, new { htmlAttributes = new { @class = "form-control", style = "width:80px" } }) @Html.ValidationMessageFor(model => model.Kintais[idx].rest, "", new { @class = "text-danger" }) </td> <td> @Html.DisplayFor(model => model.Kintais[idx].worktime) @Html.HiddenFor(model => model.Kintais[idx].worktime) </td> <td> @Html.DisplayFor(model => model.Kintais[idx].overtime) @Html.HiddenFor(model => model.Kintais[idx].overtime) </td> <td> @Html.DropDownListFor(model => model.Kintais[idx].situation, dictionary[Model.Kintais[idx].situation], new { htmlAttributes = new { @class = "form-control" } }) </td> <td style="width: 66px"> <nobr> <button type="button" onclick="setRegularWorkTime('@Html.IdFor(model => model.Kintais[i].open)', '@Html.IdFor(model => model.Kintais[i].close)', '@Html.IdFor(model => model.Kintais[i].rest)')" class="btn btn-primary"> 定時 </button> </nobr> </td> <td> @Html.EditorFor(model => model.Kintais[idx].remark, new { htmlAttributes = new { @class = "form-control"} }) @Html.ValidationMessageFor(model => model.Kintais[idx].remark, "", new { @class = "text-danger" }) </td> @Html.HiddenFor(model => model.Kintais[idx].emp_num) @Html.HiddenFor(model => model.Kintais[idx].date) @Html.HiddenFor(model => model.Kintais[idx].id) </tr> } </table> </body> }
回答1件
あなたの回答
tips
プレビュー