CSS中的标志从底部到顶部的动画

huangapple go评论90阅读模式
英文:

Animation in CSS for logo that goes from bottom to top

问题

以下是您要翻译的部分:

"Hi i try to get animation on my index.html with my style.css but it does not work and i dont understood why.

Here's my code :

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=chrome">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <link rel="stylesheet" href="styles/style.css">
  8. <title>Arrow</title>
  9. </head>
  10. <body>
  11. <span><span><img src="img/Arrow_logo.png"></span></span>
  12. <div class="affiche">
  13. <img src="img/arrow-season-5-poster.jpg" width="34%">
  14. </div>
  15. <div class="navigation">
  16. <button><a href="pages/page2.html">Flash</a></button>
  17. </div>
  18. </body>
  19. </html>
  1. body {
  2. background: #333;
  3. }
  4. .affiche {
  5. background-color: #333;
  6. color: #fff;
  7. text-align: center;
  8. }
  9. .navigation {
  10. background-color: #333;
  11. color: #666;
  12. text-align: center;
  13. }
  14. @keyframes spanFadeIn {
  15. 0% {
  16. transform: translateY(100%);
  17. }
  18. 100% {
  19. transform: translateY(0%);
  20. }
  21. }
  22. span {
  23. overflow: hidden;
  24. display: block;
  25. span {
  26. display: block;
  27. animation: spanFadeIn 500ms ease-in-out;
  28. }
  29. }

I tried in sass but it broke everything in my html."

英文:

Hi i try to get animation on my index.html with my style.css but it does not work and i dont understood why.

Here's my code :

  1. &lt;!DOCTYPE html&gt;
  2. &lt;html lang=&quot;en&quot;&gt;
  3. &lt;head&gt;
  4. &lt;meta charset=&quot;UTF-8&quot;&gt;
  5. &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=chrome&quot;&gt;
  6. &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
  7. &lt;link rel=&quot;stylesheet&quot; href=&quot;styles/style.css&quot;&gt;
  8. &lt;title&gt;Arrow&lt;/title&gt;
  9. &lt;/head&gt;
  10. &lt;body&gt;
  11. &lt;span&gt;&lt;span&gt;&lt;img src=&quot;img/Arrow_logo.png&quot;&gt;&lt;/span&gt;&lt;/span&gt;
  12. &lt;div class=&quot;affiche&quot;&gt;
  13. &lt;img src=&quot;img/arrow-season-5-poster.jpg&quot; width=&quot;34%&quot;&gt;
  14. &lt;/div&gt;
  15. &lt;div class=&quot;navigation&quot;&gt;
  16. &lt;button&gt;&lt;a href=&quot;pages/page2.html&quot;&gt;Flash&lt;/a&gt;&lt;/button&gt;
  17. &lt;/div&gt;
  18. &lt;/body&gt;
  19. &lt;/html&gt;
  1. body {
  2. background: #333;
  3. }
  4. .affiche {
  5. background-color: #333;
  6. color: #fff;
  7. text-align: center;
  8. }
  9. .navigation {
  10. background-color: #333;
  11. color: #666;
  12. text-align: center;
  13. }
  14. @keyframes spanFadeIn {
  15. 0% {
  16. transform: translateY(100%);
  17. }
  18. 100% {
  19. transform: translateY(0%);
  20. }
  21. }
  22. span {
  23. overflow: hidden;
  24. display: block;
  25. span {
  26. display: block;
  27. animation: spanFadeIn 500ms ease-in-out;
  28. }
  29. }

I tried in sass but it broke everything in my html.

答案1

得分: 0

你的CSS文件中使用了SASS代码(这是不正确的),而不是嵌套 spans,请使用以下标记:

  1. body {
  2. background: #333;
  3. }
  4. .affiche {
  5. background-color: #333;
  6. color: #fff;
  7. text-align: center;
  8. }
  9. .navigation {
  10. background-color: #333;
  11. color: #666;
  12. text-align: center;
  13. }
  14. @keyframes spanFadeIn {
  15. 0% {
  16. transform: translateY(100%);
  17. }
  18. 100% {
  19. transform: translateY(0%);
  20. }
  21. }
  22. span {
  23. overflow: hidden;
  24. display: block;
  25. }
  26. span span {
  27. display: block;
  28. animation: spanFadeIn 500ms ease-in-out;
  29. }
英文:

You are using SASS code in CSS file (which is incorrect), instead of nesting spans use the notation below:

  1. body {
  2. background: #333;
  3. }
  4. .affiche {
  5. background-color: #333;
  6. color: #fff;
  7. text-align: center;
  8. }
  9. .navigation {
  10. background-color: #333;
  11. color: #666;
  12. text-align: center;
  13. }
  14. @keyframes spanFadeIn {
  15. 0% {
  16. transform: translateY(100%);
  17. }
  18. 100% {
  19. transform: translateY(0%);
  20. }
  21. }
  22. span {
  23. overflow: hidden;
  24. display: block;
  25. }
  26. span span {
  27. display: block;
  28. animation: spanFadeIn 500ms ease-in-out;
  29. }

huangapple
  • 本文由 发表于 2023年3月21日 01:12:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/75793326.html