html tr的长度,javascript-如何根据文本长度使表td tr自动宽度?

我的桌子宽度为100%,如何根据文本长度自动宽度设置TD和TR?我使用width:自动,但是不起作用.这是我的代码:

.hoverTable {

width: 100%;

border-collapse: collapse;

}

.hoverTable td {

padding: 7px;

border: #4e95f4 1px solid;

}

/* Define the default color for all the table rows */

.hoverTable tr {

background: #b8d1f3;

}

/* Define the hover highlight color for the table row */

.hoverTable tr:hover {

background-color: #ffff99;

}

.hoverTable th {

background: #b8d1f3;

}

Some Text here
This is text length example and textItem 1BItem 1C
Item 2AItem 2BItem 2C
Item 3AItem 3BItem 3C
Item 4AItem 4BItem 4C
Item 5AItem 5BItem 5C

正如您在“这是文本长度”示例中看到的那样,并且文本的宽度不是基于文本长度的,我如何才能基于文本长度来设置宽度.

我的意思是基于文本长度的自动宽度?

谢谢

解决方法:

使用以下内容:

.hoverTable {

border-collapse: collapse;

}

因此,只需删除宽度:100%;它会工作.该表现在将动态呈现.

标签:css,html,javascript

来源: https://codeday.me/bug/20191119/2036635.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值