html - 宽度,最大宽度不适用于
问题描述
我需要为我的文本设置最大宽度,以防文本太长。我试图设置“宽度”和“最大宽度”,但没有成功。
现在它看起来与太长的文本。
<tr>
<td class="no-wrap">
<div class="grid-item-margin-left">@Html.DisplayFor(m => checkListItem.StepNumber).</div>
</td>
<td>
@Html.DisplayFor(m => description)
</td>
我的问题在
<td>
@Html.DisplayFor(m => description)
</td>
我试过这个解决方案:
<td>
<p style="max-width:60ch">@description</p>
</td>
但是第二个屏幕上的结果:
更新:感谢您的建议!我试过这个
.long-text-trim {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 60ch;
}
它有效。但!我还有另一个问题:当我最小化窗口时,我想更多地修剪文本。如何实施?
解决方案
这很好用:
.long-text-trim {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 20vw;
}
推荐阅读
- javascript - 将数据从 JS 发送到 python
- mysql - SQL根据第一个表中的时间差连接第二个表
- typescript - 带有返回类型注释的 TypeScript 过多属性错误,但在实现接口时没有
- laravel-5 - Laravel 5.4 找不到请求的 URL
- html - CSS过滤器导致定位问题
- javascript - 将数组格式化为对象 javascript
- android - Android音频播放器中的下一首歌曲按钮和上一首歌曲按钮
- javascript - 无法从另一个 javascript 文件的类访问一个 javascript 文件
- javascript - 使用multer从客户端获取详细信息后,如何在nodejs中以base64编码文件
- python - OpenCV - 用霍夫变换找不到垂直线