【HTML】table 1px border,td文本超出隐藏

效果图
在这里插入图片描述
html代码

<table className={styles.conver_table} border={1}>
    <thead>
        <tr>
            <th>序号</th>
            <th>标题</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        {
            new Array(20).fill({}).map((v, i) => {
                return <tr key={i}>
                    <td>{i + 1}</td>
                    <td>
                        <span className={styles.title_content}>在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份</span>
                    </td>
                    <td>
                        <span className={styles.cloud_btn}>同步云端</span>
                    </td>
                </tr>
            })
        }
    </tbody>
</table>

css代码

.conver_table {
    width: 100%;
    border: 1px solid var(--border-primary);
    // 1px border关键属性
    border-collapse:collapse;
    // td内容超出隐藏的关键属性
    table-layout: fixed;

    tr {
        font-size: 1.4rem;

        th, td {
            font-family: var(--font-1);

            &:nth-child(1) {
                width: 6rem;
            }
            &:nth-last-child(1) {
                width: 10rem;
            }
        }

        th {
            height: 3rem;
            font-size: 1.8rem;
            font-weight: 500;
        }

        td {
            height: 2.4rem;
            text-align: center;

            span {
                display: inline-block;

                &.title_content {
                    width: 100%;
                    box-sizing: border-box;
                    padding: 0 0.5rem;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                }

                &.cloud_btn {
                    color: var(--red-light);
                    font-size: 1.2rem;
                    font-weight: 600;
                    cursor: pointer;
                }
            }
        }
    }
}
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值