Animating margins and padding with CSS Transition causes jumpy animation

时间秒杀一切 提交于 2019-12-05 01:39:39

I believe the issue is because you are transitioning the margins (and using negative margins which is always a little wonky).

A smoother solution might be using transform: scale(x)

someting like:

header nav .icon-border {
  display: inline-block;
  border: 2px solid #000;
  border-radius: 30px;
  padding: 5px;
  margin: 0 10px;
  transform: scale(1); /* you need a scale here to allow it to transition in both directions */
  transition: 0.15s all ease;
}

header nav a:hover .icon-border {
  transform: scale(1.2);
  border: 2px solid #ddd;
}

Maybe this works:

header nav a {
  display: inline-block;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!