使用引导程序的图像标签宽度和高度

时间:2014-06-03 20:00:20

标签: css asp.net-mvc image twitter-bootstrap

我有一个名为ProductSummary.cshtml的视图,它正在从数据库加载图像。为什么我在img标签中指定它被忽略的高度?图像尺寸为235像素×234像素

ProductSummary:

@model SportsStore.Domain.Entities.Product

<div class="well">

@if (Model.ImageData != null)
{
<div class="pull-left" style="margin-right: 10px">
 <img class="img-thumbnail" height="75"
  src="@Url.Action("GetImage", "Product",
   new { Model.ProductID })" />
</div>
}


<h3>
    <strong>@Model.Name</strong>
    <span class="pull-right label label-primary">@Model.Price.ToString("c")</span>
</h3>

@using (Html.BeginForm("AddToCart", "Cart"))
{
    <div class="pull-right">
        @Html.HiddenFor(x => x.ProductID)
        @Html.Hidden("returnUrl", Request.Url.PathAndQuery)
        <input type="submit" class="btn btn-success" value="Add to cart" />
    </div>
}
<span class="lead"> @Model.Description</span>
</div>

当我使用谷歌浏览器检查元素时,我得到以下信息:

.img-thumbnail {
display: inline-block;
height: auto;
max-width: 100%;
padding: 4px;
line-height: 1.428571429;
background-color: #ffffff;
border: 1px solid #dddddd;
border-radius: 4px;
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}

1 个答案:

答案 0 :(得分:1)

您可以尝试为图像执行内联样式

<img class="img-thumbnail" style="height:75px; width:auto;"
  src="@Url.Action("GetImage", "Product",
   new { Model.ProductID })" />