img
当父标记a
悬停时,我想移至顶部4px 。所以我有这样的事情:
<a href="">
<img src="GitHub.png" alt="GitHub" />
</a>
而我的CSS:
a:hover > img {
position: relative;
bottom: 4px;
}
当我申请transition
到a
或者img
,它不顺畅。我怎么了
使用transform
代替bottom
。
a:hover > img {
position: relative;
transform: translateY(-4px);
}
img {
transition: transform 1s;
}
<a href="">
<img src="https://placehold.it/50" alt="GitHub" />
</a>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句