【发布时间】:2021-12-07 22:44:36
【问题描述】:
我想在 CSS 中实现一个简单的悬停动画,但是在悬停时,动画会跳跃/轻弹,让它看起来很傻。有没有办法避免这种情况?我希望下拉图像消失,标签滑回原来的位置。
.elementor-widget-wp-widget-woocommerce_product_categories .product-categories li > a:before {
background: url("/dropdown.svg") no-repeat center/contain;
content: "";
border: none;
display: inline-block;
height: 1em;
opacity: 0;
transform: rotate(-90deg);
transition-property: margin,opacity;
width: 1em;
}
.elementor-widget-wp-widget-woocommerce_product_categories .product-categories li > a:hover::before {
opacity: 1;
transition: .3s ease all;
}
.product-categories li > a:hover{
margin-left: 30px;
}
.elementor-widget-wp-widget-woocommerce_product_categories .product-categories li a:after {
content: none;
}
【问题讨论】:
-
margin占实际空间,可以使用translate移动不跳转
标签: css animation hover elementor