css link element jumps on hover

前端 未结 2 2250
执笔经年
执笔经年 2020-12-15 02:58

I am trying to put a border around a link on hover, and the style applies to it, but it jumps (the element jumps) when i hover over it... what can I do? code:



        
2条回答
  •  Happy的楠姐
    2020-12-15 03:17

    You 'jump' is caused by the 1px height of the border, that make your li move

    You might use

     .navigation li:hover {
       border-color: #ccc;
     }
    
     .navigation li {
       border: 1px solid #;
     }
    

    instead. This way, the border is here from the beginning, so no jump on hovering, and it's invisible, since it's the same color of the parent container or transparent.

提交回复
热议问题