html table td超出内容自动隐藏,鼠标经过时显示

html table td超出内容自动隐藏,鼠标经过时显示

css

table{
  width:100%;
  table-layout: fixed;
}
.autocut{
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
  -o-text-overflow:ellipsis;
  -icab-text-overflow: ellipsis;
  -khtml-text-overflow: ellipsis;
  -moz-text-overflow: ellipsis;
  -webkit-text-overflow: ellipsis;
}
.autocut:hover
{
  overflow:visible;
  white-space:normal;
  word-wrap: break-word;
}

将autocut 样式添加到需要自动裁剪的标签上

 <table class="table table-striped table-bordered" style="margin:0">
        <thead>
        <tr>
          <th scope="col">jobId</th>
          <th scope="col">yarnApplicationId</th>
          <th scope="col">jobName</th>
          <th scope="col">createData</th>
          <th scope="col">updateData</th>
          <th scope="col">status</th>
          <th scope="col">author</th>
          <th scope="col">desc</th>
          <th scope="col">option</th>
        </tr>
        </thead>
        <tbody>
        <tr>
          <td>1000001</td>
          <td>application_1676556081816_0001</td>
          <td>sqlTestDemo</td>

          <td>2023-01-12 14:28:56</td>
          <td>-</td>
          <td><span style="line-height: 18px; font-size: 18px;" class="badge text-bg-primary">create</span></td>
          <td>kuro</td>
          <td  class="autocut">
            this is requirement is use riverMaps platform implement a simple stream process app
            this is requirement is use riverMaps platform implement a simple stream process app
            this is requirement is use riverMaps platform implement a simple stream process app
            this is requirement is use riverMaps platform implement a simple stream process app

          </td>
          <td>
            <button style="margin: 0 8px" class="btn btn-warning">restart</button>
            <button style="margin: 0 8px" class="btn btn-danger">kill</button>
          </td>
        </tr>
        </tbody>
      </table>

效果如下 :

在这里插入图片描述

在这里插入图片描述

方案2:

不采用fixed layout, 可自定义td宽度

css

<style>
        table {
            width: 100%;
            /*table-layout: fixed;*/
        }

        table tr {
            margin-right: 10px;
        }

        table td {
            max-width: 80px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            margin-top: 24px;
        }

        table td:hover {
            overflow: visible;
            white-space: normal;
            word-wrap: break-word;
        }
 </style>
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值