Cra*_*igF 2 css-tables tablecolumn
我有一个由表生成器构建的基本表。
我只需要增加第一个表列的大小。但是,下面的代码增加了第一列和第四列。
CSS
table.paleBlueRows {
font-family: Arial, Helvetica, sans-serif;
border: 1px solid #FFFFFF;
width: 85%;
height: 200px;
text-align: center;
border-collapse: collapse;
}
table.paleBlueRows td, table.paleBlueRows th {
border: 1px solid #0B6FA4;
padding: 3px 2px;
}
table.paleBlueRows tbody td {
font-size: 13px;
}
table.paleBlueRows td:nth-child(even) {
background: #D0E4F5;
}
table.paleBlueRows thead {
background: #0B6FA4;
border-bottom: 3px solid #FFFFFF;
}
table.paleBlueRows thead th {
font-size: 17px;
font-weight: bold;
color: #FFFFFF;
text-align: center;
border-left: 2px solid #FFFFFF;
border-TOP: 2px solid #FFFFFF;
}
table.paleBlueRows thead th:first-child {
border-left: none;
width: 8em;
min-width: 8em;
max-width: 8em;
}
table.paleBlueRows tfoot td {
font-size: 14px;
}
Run Code Online (Sandbox Code Playgroud)
下面的代码控制列宽
}
table.paleBlueRows thead th:first-child {
border-left: none;
width: 8em;
min-width: 8em;
max-width: 8em;
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以协助增加第一列吗?
这是CODEPEN
小智 5
它增加了第一个标题包的宽度,因为您正在使用 CSS 选择器 table.paleBlueRows thead th:first-child。
虽然,第 4 列也受到影响,因为您有一个 rowspan 并且列 Each 也被选中 - 它是跨行的第一列。
要解决此问题,您可以使用选择器 table.paleBlueRows td:first-child 只影响表格行的第一个 td 元素。
代替:
table.paleBlueRows thead th:first-child {
border-left: none;
width: 8em;
min-width: 8em;
max-width: 8em;
}
Run Code Online (Sandbox Code Playgroud)
和:
table.paleBlueRows td:first-child {
border-left: none;
width: 8em;
min-width: 8em;
max-width: 8em;
}
Run Code Online (Sandbox Code Playgroud)
请检查我的评论笔:https : //codepen.io/Rechousa/pen/mXXPwW