如果我的表格宽度设置为 100%,我可以固定 td 大小吗?
这是我的 CSS:
table{
margin-left:auto;
margin-right:auto;
table-layout: fixed;
width:100%;
border:1px solid black;
}
td {
overflow: hidden;
width: 20px;
height: 20px;
white-space: nowrap;
}
如果我不把table widht设置成100%,就全部固定为20px x 20px,否则不会...
最佳答案
在 td
元素上应用 display: inline-block;
定义,现在您可以指定宽度和高度。 ;)
例如:
td {
display: inline-block;
width: 50px;
height: 50px;
}
关于html - 当表格为 100% 时,CSS 固定 td 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28771025/