如何让边框只出现在顶部?

How can I make a border only appear on the top?

如何让鼠标悬停在边框上时只在顶部显示边框? 代码:

 a:hover {
    border-top: 3px white;
    border-style: solid;
 }

它使边框仍然出现在所有边上,但我希望它只出现在顶部。

a:hover {
border-top: 3px white;
border-style: solid;
border-bottom: 0px white;
border-right: 0px white;
border-left: 0px white;

} 固定它。现在只出现在顶部。 :)

请尝试以下代码。

border-style: solid;
border-top: thick double green;
border-left:0;
border-bottom:0;
border-right:0;

我认为当您使用 solid 时它会在所有边上绘制边框。上面的代码实际上会去掉所有三个边的边框,但不会去掉顶部的边框。

您还可以使用:

a:hover {border-top: 3px solid white; border-right: 0; border-bottom: 0; border-left: 0;}

如果 link 的常规状态使用所有四个边框,那么如果您只想要 :hover 上的上边框,则将 0 用于右边框、下边框和左边框。