GVKun编程网logo

如何使用 CSS 动画在文本块上方的 2 秒内使文本滑动(css 文字动画)

1

对于如何使用CSS动画在文本块上方的2秒内使文本滑动感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍css文字动画,并为您提供关于)预期css(css-rparentexpected)"用于@m

对于如何使用 CSS 动画在文本块上方的 2 秒内使文本滑动感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍css 文字动画,并为您提供关于) 预期 css(css-rparentexpected)" 用于@media 查询中的第 4 级 css 语法、 不起作用、Angular:

    添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css的有用信息。

    本文目录一览:

    如何使用 CSS 动画在文本块上方的 2 秒内使文本滑动(css 文字动画)

    如何使用 CSS 动画在文本块上方的 2 秒内使文本滑动(css 文字动画)

    如何解决如何使用 CSS 动画在文本块上方的 2 秒内使文本滑动

    我正在尝试使用 HTML 和 CSS 动画让一些文本从左侧滑动到网页的中心。目标是让第一个文本块首先滑入中心,然后在 2 秒延迟后,让第二个文本块滑入中心。这样就可以有很好的效果,让读者看到页面上写的行。

    这是HTML代码:

    1. /* .slide1 {
    2. -webkit-animation : slideIn 2s forwards;
    3. -moz-animation : slideIn 2s forwards;
    4. animation : slideIn 2s forwards;
    5. } */
    6. .slide2 {
    7. /* animation-delay: 2s; */
    8. margin-top : -20px;
    9. -webkit-animation : slideIn 2s forwards;
    10. -moz-animation : slideIn 2s forwards;
    11. animation : slideIn 2s forwards;
    12. }
    13. @-webkit-keyframes slideIn {
    14. 0% { transform: translateX(-900px); }
    15. 100% { transform: translateX(0); }
    16. }
    17. @-moz-keyframes slideIn {
    18. 0% { transform: translateX(-900px); }
    19. 100% { transform: translateX(0); }
    20. }
    21. @keyframes slideIn {
    22. 0% { transform: translateX(-900px); }
    23. 100% { transform: translateX(0); }
    24. }
    1. <h1 class="slide1">You want to go to the moon.<br></h1>
    2. <h1 class="slide2">We’re here to give you a shot.</h1>

所以问题是,当您取消注释上面的类 slide1 时,动画适用于第二行,但不适用于第一行。
整个事情一起移动,这不是应该发生的事情。在 Slide2 中延迟动画的意义在于,在第一个文本块移动到中心后,第二个文本块将开始向右移动。
令人困惑的是为什么这不起作用 -

  • 如果您对此有任何解决方案,请分享它们!

解决方法

您必须首先将 .slide1.slide2 置于屏幕外

  1. transform : translateX(-100vw);

...与您想象的相反,css 命令也必须遵守顺序,并且您的 delay 命令必须放在 translate

的全局命令之后

⛐ ? 非常非常糟糕 :

  1. animation-delay : 2s;
  2. animation : 2s slideIn forwards;

(它使 animation-delay : 0;

? ? :

  1. animation : 2s slideIn forwards;
  2. animation-delay : 2s;

。 否则你必须尊重参数的正确顺序

  1. animation : 2s 2s slideIn forwards;

但在我看来最好的写法是 - 不重复 css:

  1. .slide {
  2. text-align : center;
  3. transform : translateX(-100vw);
  4. animation : 2s slideIn forwards;
  5. }
  6. .second {
  7. margin-top : -.8em;
  8. animation-delay : 2s;
  9. }
  10. @keyframes slideIn {
  11. 0% { transform : translateX(-100vw); }
  12. 100% { transform : translateX(0); }
  13. }
  1. <h1 class="slide">You want to go to the moon.</h1>
  2. <h1 class="slide second">We’re here to give you a shot.</h1>

还要注意单位的使用,以及无论显示的宽度如何(如您在问题中所指出的)将文本居中的正确方法

) 预期 css(css-rparentexpected)

) 预期 css(css-rparentexpected)" 用于@media 查询中的第 4 级 css 语法

Visual Studio Code does not support 4 级范围语法呢。此外,MDN 表示目前只有 Firefox 支持该语法。如果您需要跨浏览器支持,您现在需要坚持使用原始的 max-width 语法:

@media (max-width: 768px) {
    h1 {
        font-size: 3em;
        color: mediumvioletred;
    }
    nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: mediumaquamarine;
    }
}

否则,你所拥有的是正确的。

" alt="">

OSC 请你来轰趴啦!1028 苏州源创会,一起寻宝 AI 时代

css 样式   引入  href="css/layout.css?id=7" 是什么意思?

不起作用" alt=" 不起作用">

如何解决<link rel="stylesheet" type="text/css" href="{% static ''css/style.css'' %}"> 不起作用

我在 vs-code 上将 css 链接到 html。 center-aliend 在这里不起作用。有没有人知道哪个部分有问题? 我想设置文本“Hello Static!!”到浏览器的中心。

  1. {% load static %}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <Meta charset="UTF-8">
  6. <Meta name="viewport" content="width=device-width,initial-scale=1.0">
  7. <link rel="stylesheet" type="text/css" href="{% static ''css/style.css'' %}">
  8. <title>Static Practice</title>
  9. </head>
  10. <body>
  11. <div>Hello Static!!</div>
  12. </body>
  13. </html>

  1. body {
  2. text-align: center;
  3. }

  1. # Static files (CSS,JavaScript,Images)
  2. # https://docs.djangoproject.com/en/3.1/howto/static-files/
  3. STATIC_URL = ''/static/''
  4. STATICFILES_Dirs = [
  5. BASE_DIR / ''static''
  6. ]

Browser output

Angular: <ol> 添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css

Angular:
    添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css

如何解决Angular: <ol> 添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css

我正在 angular 中创建富文本编辑器,当我执行 document.execCommand(''insertOrderedList'') 时,我得到 <ol> 项,它不受我组件的 css 的影响,只有 styles.css 中的 css(主 css 文件在项目的根目录)影响我使用 document.execCommand 添加的项目。 是否有可能改变这种行为?

解决方法

当然。它的名字是view encapsulation。将其更改为 ViewEncapsulation.none 会产生所需的行为。

  1. @Component({
  2. ...
  3. encapsulation: ViewEncapsulation.none
  4. })

关于如何使用 CSS 动画在文本块上方的 2 秒内使文本滑动css 文字动画的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于) 预期 css(css-rparentexpected)" 用于@media 查询中的第 4 级 css 语法、 不起作用、Angular:

    添加的 document.execCommand 只看到 style.css 中的 css 规则而不是组件的 css的相关知识,请在本站寻找。

    本文标签:

上一篇如何在一个 React 组件渲染的多个项目中使用 CSS 网格?(react组件渲染两次)

下一篇JS 文件不能在 angular 中工作,但可以在普通的 HTML、CSS+JS 中工作(为什么js文件不起作用)