私はaspmvcに組み込まれているテーブルビューに基づいてオブジェクトのリストを取得しました。このように見えます。 Asp MVCテーブルオブジェクトを中心にするには?
問題は、すべての要素を中央に揃えることです。コードはかなり一般的です。文字通り私が信じる生成コードです。
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.m_EmailAddress)
</th>
<th>
@Html.DisplayNameFor(model => model.m_FirstName)
</th>
<th>
@Html.DisplayNameFor(model => model.m_LastName)
</th>
<th>
@Html.DisplayNameFor(model => model.m_CellNumber)
</th>
<th>
@Html.DisplayNameFor(model => model.m_CompanyName)
</th>
<th>
@Html.DisplayNameFor(model => model.m_CompanyAddress)
</th>
<th>
@Html.DisplayNameFor(model => model.m_CompanyState)
</th>
<th>
@Html.DisplayNameFor(model => model.m_CompanyZip)
</th>
<th>
@Html.DisplayNameFor(model => model.m_CompanyPhone)
</th>
<th>
@Html.DisplayNameFor(model => model.m_CompanyWebsite)
</th>
<th>
@Html.DisplayNameFor(model => model.m_WorkTravelRange)
</th>
<th>
@Html.DisplayNameFor(model => model.m_CompanyCostCode)
</th>
<th>
@Html.DisplayNameFor(model => model.m_CompanyAccountType)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.m_EmailAddress)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_FirstName)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_CellNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_CompanyName)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_CompanyAddress)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_CompanyState)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_CompanyZip)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_CompanyPhone)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_CompanyWebsite)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_WorkTravelRange)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_CompanyCostCode)
</td>
<td>
@Html.DisplayFor(modelItem => item.m_CompanyAccountType)
</td>
@*<td>
@Html.ActionLink("Edit", "Edit", new { id=item.m_IdentityCode }) |
@Html.ActionLink("Details", "Details", new { id=item.m_IdentityCode }) |
@Html.ActionLink("Delete", "Delete", new { id=item.m_IdentityCode })
</td>*@
私の本能は...無駄にするのではなく、
<table class = "table" align = "center">
に教えてください。
私は正しい方向に向いていますか?お願いしてありがとう。
編集:
私は<th text-align: center>
を試みたが、それはまだ整列左に見えます。
スタイルを参照しているサイトのCSSファイル内のコードを置くことができます 'th'とテキスト整列'と 'td'要素:center' –
@StephenMueckeはありがとう、サー。 – Eidenai
@StephenMuecke私は質問を更新し、まだ一列に並ぶように見えます。 – Eidenai