【问题标题】:CSS text.overflow with @Html.LabelForCSS text.overflow 与 @Html.LabelFor
【发布时间】:2015-09-08 19:14:07
【问题描述】:

当我的引导 div 列太小时,我想在 @Html.LabelFor 的末尾插入省略号。

如果我使用静态文本,它会正确显示为

Lorem ips...

已显示,但只要我使用 @Html.LabelFor,它就会将其切断为

Lorem ips

最后没有 ...。

这里是我的代码:-

    <style>
        .hideOverflow {
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            display: inline-block;
        }
    </style>

        <div class="row">
            <div class="col-md-1 hideOverflow">
                Lorem ipsum dolor sit amet, consectetur adipiscing elit.
@*                @Html.LabelFor(model => model.Balloon)*@
            </div>
            <div class="col-md-4">
                @Html.EditorFor(model => model.Balloon)
                @Html.ValidationMessageFor(model => model.Balloon)
            </div>
        </div>

任何帮助将不胜感激。

【问题讨论】:

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


    【解决方案1】:

    @Html.LabelFor 被渲染为&lt;label&gt; 你应该为&lt;label&gt;而不是div写你的css

    类似以下的东西

    .hideOverflow label{
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            display: inline-block;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-21
      • 1970-01-01
      • 1970-01-01
      • 2013-08-28
      • 1970-01-01
      相关资源
      最近更新 更多