我正在尝试制作一个单元格表格,其中一些可以在逻辑上组合在一起,当它们悬停在它们上面时会改变颜色。
我开始使用HTML标记表但很快就知道你不能在内部嵌套div或spans,所以它意味着为每个单独的单元格(256个单元格)分配一个类,可能还有一两个javascript函数。
我使用了div构建的表,起初看起来似乎更好,但是尝试逻辑分组单元格导致表格搞乱:
最终目标是256个单元格,其中一些可以被串在一起,例如单元格16-31(整个第二行)或单元格30-33(另一行的前几个单元格)。每组细胞都有一种颜色,当任何细胞悬停时,整个组都会改变颜色。
我的主要问题是,是否有一个"隐形"不会被放置在该地方的html标签(没有该ID"特殊" div,表格布局如预期的那样)。到目前为止,我已经尝试了div(如图),跨度和部分。或者,更好的建议解决方案也会有所帮助。
body {
font-family: Consolas, Courier New, Courier, monospace;
}
.divTable {
border: 2px solid #999999;
display: table;
width: auto;
}
.divTableRow {
display: table-row;
}
.divTableCell,
.divTableHead {
vertical-align: middle;
text-align: center;
border: 1px solid #999999;
display: table-cell;
height: 25px;
width: 25px;
/*padding: 3px;*/
}
.divTableHeading {
background-color: beige;
font-weight: bold;
}
.divTableBody {
display: table-row-group;
}
/* */
/* */
/* */
.divTableCell {
background-color: green;
}
#special .divTableCell {
background-color: red;
}
body {
font-family: Consolas, Courier New, Courier, monospace;
}
th {
background-color: beige;
}
.divTableCell:hover {
cursor: pointer;
}
.endrow .divTableCell:hover,
.divTableHeading .divTableCell:hover {
cursor: default;
}
.endrow,
.reserved {
background-color: lightpink;
}
/*.reserved:hover {
background-color: red;
}*/

<div class="divTable">
<div class="divTableBody">
<div class="divTableRow divTableHeading">
<div class="divTableCell">+</div>
<div class="divTableCell">00</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">16</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">32</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">48</div>
<div id="special">
<div class="divTableCell">30</div>
<div class="divTableCell">31</div>
<div class="divTableCell">32</div>
<div class="divTableCell">33</div>
</div>
<div class="divTableCell">34</div>
<div class="divTableCell">35</div>
<div class="divTableCell">36</div>
<div class="divTableCell">37</div>
<div class="divTableCell">38</div>
<div class="divTableCell">39</div>
<div class="divTableCell">3A</div>
<div class="divTableCell">3B</div>
<div class="divTableCell">3C</div>
<div class="divTableCell">3D</div>
<div class="divTableCell">3E</div>
<div class="divTableCell">3F</div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow endrow">
<div class="divTableCell divTableHeading">256</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
</div>
</div>
&#13;
答案 0 :(得分:1)
使用jQuery或类似命令查找第38行并突出显示特殊div - 请注意我没有使用ID但只添加了一个类。 ID必须是唯一的。
现在不需要包装特殊的div。所有更改都在我调用的对象highlight
$(function() {
var highlight = { "row":"48", "cells":[1,2,3,5] }
var cells = $(".divTableHeading:contains('"+highlight.row+"')").siblings();
$.each(highlight.cells,function(_,i) {
cells.eq(i).addClass("special")
});
$(".divTable .special").hover(function() {
$(this).toggleClass("reserved");
});
});
body {
font-family: Consolas, Courier New, Courier, monospace;
}
.divTable {
border: 2px solid #999999;
display: table;
width: auto;
}
.divTableRow {
display: table-row;
}
.divTableCell,
.divTableHead {
vertical-align: middle;
text-align: center;
border: 1px solid #999999;
display: table-cell;
height: 25px;
width: 25px;
/*padding: 3px;*/
}
.divTableHeading {
background-color: beige;
font-weight: bold;
}
.divTableBody {
display: table-row-group;
}
/* */
/* */
/* */
.divTableCell {
background-color: green;
}
.special {
background-color: red;
}
body {
font-family: Consolas, Courier New, Courier, monospace;
}
th {
background-color: beige;
}
.divTableCell:hover {
cursor: pointer;
}
.endrow .divTableCell:hover,
.divTableHeading .divTableCell:hover {
cursor: default;
}
.endrow,
.reserved {
background-color: lightpink;
}
/*.reserved:hover {
background-color: red;
}*/
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="divTable">
<div class="divTableBody">
<div class="divTableRow divTableHeading">
<div class="divTableCell">+</div>
<div class="divTableCell">00</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">16</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">32</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">48</div>
<div class="divTableCell">30</div>
<div class="divTableCell">31</div>
<div class="divTableCell">32</div>
<div class="divTableCell">33</div>
<div class="divTableCell">34</div>
<div class="divTableCell">35</div>
<div class="divTableCell">36</div>
<div class="divTableCell">37</div>
<div class="divTableCell">38</div>
<div class="divTableCell">39</div>
<div class="divTableCell">3A</div>
<div class="divTableCell">3B</div>
<div class="divTableCell">3C</div>
<div class="divTableCell">3D</div>
<div class="divTableCell">3E</div>
<div class="divTableCell">3F</div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow">
<div class="divTableCell divTableHeading">0</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
<div class="divTableRow endrow">
<div class="divTableCell divTableHeading">256</div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
<div class="divTableCell"> </div>
</div>
</div>
</div>
答案 1 :(得分:0)
我的主要问题是,是否有一个&#34;隐形&#34;不会被放置在地方的HTML标签
答案是肯定的,CSS应该提供它,......但是:
对于firefox,您可以使用(https://samrueby.com/2015/02/09/firefox-is-releasing-support-for-css-display-contents/)
include 'httpsocket.php';
$server_ip="ip"; //IP that User is assigned to
$server_login="admin";
$server_pass="mypass"";
$server_host="ip"; //where the API connects to
$server_ssl="Y";
$server_port=2222;
$username='username'
$domain='domain.com'
$email='email@email.com'
$pass='pass'
$package='package'
echo "Creating user $username on $server_ip.... <br>\n";
$sock = new HTTPSocket;
if ($server_ssl == 'Y')
{
$sock->connect("ssl://".$server_host, $server_port);
}
else
{
$sock->connect($server_host, $server_port);
}
$sock->set_login($server_login,$server_pass);
$sock->query('/CMD_ACCOUNT_RESELLER',
array(
'action' => 'create',
'add' => 'Submit',
'username' => $username,
'email' => $email,
'passwd' => $pass,
'passwd2' => $pass,
'domain' => $domain,
'package' => $package,
'ip' => $server_ip,
'notify' => 'yes'
));
$result = $sock->fetch_parsed_body();
if ($result['error'] != "0")
{
echo "<b>Error Creating user $username on server $server_ip:<br>\n";
echo $result['text']."<br>\n";
echo $result['details']."<br></b>\n";
}
else
{
echo "User $username created on server $server_ip<br>\n";
}
exit(0);
对于另一个<强>
display:contents;
强>这些值定义元素是否完全生成显示框。
<display-box>
内容这些元素不会自行生成特定的框。它们被伪盒子和子盒子取代。
无关闭元素的显示(它对布局没有影响);所有后代元素也都关闭了它们的显示。该文档呈现为好像该元素不存在。
要呈现元素框的尺寸,但其内容不可见,请参阅visibility属性。
,您需要jquery来克隆子项并删除#special。如果您需要特殊样式,还需要添加一个类:
Value Description
演示如下:
$('#special>div').clone().insertAfter('#special').addClass( "special" );
$('#special').remove();
&#13;
// for none firefox browsers
$('#special>div').clone().insertAfter('#special').addClass( "special" );
$('#special').remove();
$( ".divTableCell" ).each(function() {
$('.special' ).addClass( "hover" );
});
&#13;
#special {
display:contents;
}
#special .divTableCell ,.divTable .special{
background-color: red;
}
.divTable:hover .special.hover {background:turquoise;}
body {
font-family: Consolas, Courier New, Courier, monospace;
}
.divTable {
border: 2px solid #999999;
display: table;
width: auto;
}
.divTableRow {
display: table-row;
}
.divTableCell,
.divTableHead {
vertical-align: middle;
text-align: center;
border: 1px solid #999999;
display: table-cell;
height: 25px;
width: 25px;
/*padding: 3px;*/
}
.divTableHeading {
background-color: beige;
font-weight: bold;
}
.divTableBody {
display: table-row-group;
}
/* */
/* */
/* */
.divTableCell {
background-color: green;
}
body {
font-family: Consolas, Courier New, Courier, monospace;
}
th {
background-color: beige;
}
.divTableCell:hover {
cursor: pointer;
}
.endrow .divTableCell:hover,
.divTableHeading .divTableCell:hover {
cursor: default;
}
.endrow,
.reserved {
background-color: lightpink;
}
/*.reserved:hover {
background-color: red;
}*/
&#13;
Codepen to play with:如果没有在firefox下运行,则取消注释jquery脚本