【问题标题】:Image tag width and height using bootstrap使用引导程序的图像标签宽度和高度
【发布时间】:2014-07-24 07:18:03
【问题描述】:

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

产品总结:

@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;
}

【问题讨论】:

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


    【解决方案1】:

    你可以尝试为图片做一个内联样式

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

    【讨论】:

    • 我不确定内联 CSS 是否是个好主意。没有其他解决方法吗?
    猜你喜欢
    • 2015-03-26
    • 1970-01-01
    • 2021-07-31
    • 2012-06-16
    • 2020-08-11
    • 1970-01-01
    • 1970-01-01
    • 2016-09-11
    • 1970-01-01
    相关资源
    最近更新 更多