【发布时间】:2019-02-27 16:12:30
【问题描述】:
我有很多不同的视图页面,有很多表格宽度。示例:
- 查看 1 Product.cshtml:第一列的宽度为 25%,第二列的宽度为 75% 宽度
- 查看 2 Customer.cshtml:第一列的宽度为 40%,第二列的宽度为 60% 宽度
所以利用资源,我编辑了csstemplate。 How can I set table column widths in an MVC view?
只有文字,解决方案效果很好。 但是,当我添加图像时,它完全忽略了表格宽度百分比,使图像看起来非常大。我将如何解决这个问题并将图像保持在 25%?
注意:现在提供了一个静态图像进行测试,稍后将变为可变。
Site.css
.col1 {
width: 25%;
}
.col2 {
width: 75%;
}
产品索引.cshtml
@model IPagedList<ElectronicsStore.Models.Product>
@{
ViewBag.Title = "Products";
int counter = 0;
}
@using X.PagedList;
@using X.PagedList.Mvc.Core;
<table class="table" >
<thead>
<tr>
<th class="col1">
Product Image
</th>
<th class="col2">
Product Name
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.OnePageOfProducts)
{
<tr>
<td class="col1">
<img src="~/images/TV.jpg" data-holder-rendered="true" />
</td>
<td class="col2">
@item.ProductName
</td>
</tr>
}
</tbody>
</table>
@Html.PagedListPager((IPagedList)ViewBag.OnePageOfProducts, page => Url.Action("Index", new { page }))
【问题讨论】:
标签: html css image html-table