如何在整个细胞周围放置边框?

时间:2013-10-21 09:26:11

标签: html css border

我希望“内部边界”在整个细胞周围,如果集中注意力。现在它正好在这个词的长度上。 我希望边界围绕整个细胞。 我应该添加哪些代码?

td:focus{
    border: 2px inset white;
    border-width:2px;
    content: '';
    width: auto;
    height: auto;
    position: absolute;
    background: white;
}

1 个答案:

答案 0 :(得分:1)

它突出显示“单词的长度”,因为您正在重置单元格的高度和宽度(最终将其重置为其内容的长度)。要解决此问题,只需删除width: autoheight: auto

即可
td:focus{
    border: 2px inset white;
    border-width:2px;
    content: '';
    position: absolute;
    background: white;
}

JSFiddle demo