html – 在不同的事件中CSS多重转换为相同的元素

前端之家收集整理的这篇文章主要介绍了html – 在不同的事件中CSS多重转换为相同的元素前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一组链接标记出现在页面加载与translate3D.这完全没问题.但是我需要链接标签来缩放它的悬停.哪个不直接.

有没有办法用CSS实现它?
这是代码

  1. .linkblock {
  2. margin: 20% 0;
  3. }
  4. .hlink {
  5. width: 12%;
  6. height: 60px;
  7. opacity: 0;
  8. padding: 0 10px;
  9. background: rgba(0,0.3);
  10. display: inline-block;
  11. text-align: center;
  12. color: rgba(0,0.6);
  13. transition: all 0.5s ease;
  14. }
  15. .hlink:hover {
  16. transform: translate(0px,-20px);
  17. color: red;
  18. background: rgba(0,0.6)
  19. }
  20. @keyframes fadeInUp {
  21. from {
  22. opacity: 0;
  23. transform: translate3d(0,100%,0);
  24. }
  25. to {
  26. opacity: 1;
  27. transform: translate3d(0,0);
  28. }
  29. }
  30. .fadeInUp {
  31. animation: fadeInUp 0.3s ease-in both;
  32. }
  33. .linkblock a:nth-child(1) {
  34. animation-delay: 1.0s;
  35. }
  36. .linkblock a:nth-child(2) {
  37. animation-delay: 1.1s;
  38. }
  39. .linkblock a:nth-child(3) {
  40. animation-delay: 1.2s;
  41. }
  42. .linkblock a:nth-child(4) {
  43. animation-delay: 1.3s;
  44. }
  45. .linkblock a:nth-child(5) {
  46. animation-delay: 1.4s;
  47. }
  48. .linkblock a:nth-child(6) {
  49. animation-delay: 1.5s;
  50. }
  51. .linkblock a:nth-child(7) {
  52. animation-delay: 1.6s;
  53. }
  54. .linkblock a:nth-child(8) {
  55. animation-delay: 1.7s;
  56. }
最佳答案
问题是两者的使用允许你保持动画的最后状态,因此动画内的变换将覆盖悬停上永远不会被激活的变换.

您可以将动画拆分为2个动画并使用仅具有不透明度的两个或前向动画,并且您可以在动画完成后进行转换.

  1. .linkblock {
  2. margin: 20% 0;
  3. }
  4. .hlink {
  5. width: 12%;
  6. height: 60px;
  7. padding: 0 10px;
  8. background: rgba(0,0.6);
  9. transition: all 0.5s ease;
  10. opacity:0;
  11. }
  12. .hlink:hover {
  13. transform: translate(0px,-20px) scale(1.2);
  14. color: red;
  15. background: rgba(0,0.6)
  16. }
  17. @keyframes fadeInUp {
  18. from {
  19. transform: translate3d(0,0);
  20. }
  21. }
  22. @keyframes show {
  23. to {
  24. opacity:1;
  25. }
  26. }
  27. .fadeInUp {
  28. animation: fadeInUp 0.3s ease-in,show 0.3s ease-in forwards;
  29. }
  30. .linkblock a:nth-child(1) {
  31. animation-delay: 1.0s;
  32. }
  33. .linkblock a:nth-child(2) {
  34. animation-delay: 1.1s;
  35. }
  36. .linkblock a:nth-child(3) {
  37. animation-delay: 1.2s;
  38. }
  39. .linkblock a:nth-child(4) {
  40. animation-delay: 1.3s;
  41. }
  42. .linkblock a:nth-child(5) {
  43. animation-delay: 1.4s;
  44. }
  45. .linkblock a:nth-child(6) {
  46. animation-delay: 1.5s;
  47. }
  48. .linkblock a:nth-child(7) {
  49. animation-delay: 1.6s;
  50. }
  51. .linkblock a:nth-child(8) {
  52. animation-delay: 1.7s;
  53. }

猜你在找的HTML相关文章