我想通过colgroup定义cols的宽度。另外,tbody应该是可滚动的。但是不起作用。我有一个没有js的解决方案吗?
HTML
<colgroup>
<col span="1" style="width: 15%;">
<col span="1" style="width: 40%;">
<col span="1" style="width: 20%;">
<col span="1" style="width: 25%;">
</colgroup>
答案 0 :(得分:0)
添加到您的CSS:
td:nth-child(1), th:nth-child(1) {
width: 15%;
}
td:nth-child(2), th:nth-child(2) {
width: 40%;
}
td:nth-child(3), th:nth-child(3) {
width: 20%;
}
td:nth-child(4), th:nth-child(4) {
width: 25%;
}
tbody滚动在chrome中运行良好。我不知道它在其他浏览器中是怎么回事
答案 1 :(得分:0)
您需要将var actions = ["delete", "cancel", "edit", "clickbutton"];
var rights = "1001";
var currentRights = {};
function hasRight(right){
return rights[actions.indexOf(right)] === "1";
}
for(var i = 0; i < actions.length; i++){
currentRights[actions[i]] = hasRight(actions[i]);
}
console.log(currentRights);
console.log(currentRights["delete"]);
console.log(currentRights["foobar"]); // Still falsy
设置为display:inline-block;
<col>