我有下面的表和css,不能正确排列标题。我的想法是为TD和TH标签创建一个类,并在那里设置固定宽度。尽管如此,这并不适用于我。请在这里看到的代码:滚动tbody和标题没有排队
的CSS我有如下:
table#targetedAttacks
{
font-family: Arial, Sans-Serif;
font-size: 12px;
table-layout: fixed;
width: 500px
}
tbody.scrollTbl {
height: 250px;
overflow: auto;
border: 2px solid #000;
background-color:#ccc;
width: 525px;
}
table#targetedAttacks td {
background-color:#fafafa;
cursor: default;
border-bottom: 1px solid #ccc;
padding: 3px 10px;
}
tbody.scrollTbl td div {
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width:100px;
}
thead > tr, tbody{
display:block;
}
.date {
width: 20%;
}
.subject {
width: 20%;
}
.malwareName {
width: 20%;
}
.malwareCat {
width: 20%;
}
.reason {
width: 10%;
}
.recipients {
width: 10%;
}
table#targetedAttacks thead th
{
text-align: center;
background-color: #ddd;
cursor: pointer;
padding: 5px;
}
不幸的是,这只适用于当你想手动设置列的宽度。为了说明这一点,在删除'width:75px;'规则(在'table#targetedAttacks div'选择器中)后重新运行JSFiddle。 – Nate