你应该使用CSS中的相邻选择器()来实现这一点.看看,有四个项目:
这是你的CSS:
.item {
float:left;
background: #ccc;
width: 50px;
height: 50px;
border: 1px #000 solid;
border-right-width: 0;
}
.item:last-child {
border-right-width: 1px;
}
.item:hover {
border: 1px #f00 solid;
}
.item:hover + .item {
border-left-width: 0;
}
.item只是正常设置每个项目.它使右边界0.
.item:last-child使得最后一个在右边有一个钻孔器,因为它是最后一个并且旁边没有div来模拟边界.
.item:悬停使悬停的项目有一个红色边框,它是全部4种尺寸
.item:悬停.item抓取列表中的下一个项目并删除其左边框,因为它左边的项目现在有一个红色边框.