我的桌子宽度为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 text | Item 1B | Item 1C |
Item 2A | Item 2B | Item 2C |
Item 3A | Item 3B | Item 3C |
Item 4A | Item 4B | Item 4C |
Item 5A | Item 5B | Item 5C |
正如您在“这是文本长度”示例中看到的那样,并且文本的宽度不是基于文本长度的,我如何才能基于文本长度来设置宽度.
我的意思是基于文本长度的自动宽度?
谢谢
解决方法:
使用以下内容:
.hoverTable {
border-collapse: collapse;
}
因此,只需删除宽度:100%;它会工作.该表现在将动态呈现.
标签:css,html,javascript
来源: https://codeday.me/bug/20191119/2036635.html