html - 当表格为 100% 时,CSS 固定 td 大小

标签 html css html-table

如果我的表格宽度设置为 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/

相关文章:

javascript - 按钮在 Javascript 中没有响应/没有绑定(bind)

javascript - JQ列表中的按钮

html - 对齐圆圈文本

html - Django 元素 : template having node_modules which i can not find in static folder

javascript - 在弹出窗口中显示当前 URL - Safari 扩展

html - 截断列表元素中的长文本

css - 如何使用百分比来容纳 div,并不完全适合

css - 如何在 variables.scss 中导入颜色

php - Mysql 和 PHP 到 Excel

html - td 中的居中复选框(Bootstrap)