【问题标题】:How to use /deep/ in polymer with keyframes如何在关键帧的聚合物中使用 /deep/
【发布时间】:2015-02-24 20:45:48
【问题描述】:

我有 2 个聚合物组件,一个父母和一个孩子。因为我知道我将不得不创建更多的孩子,所以我想将我的 css 代码移动到父母中,这样每个孩子都可以使用它。我说移动我的代码,到目前为止一切都很好。

旧代码

        .decale01 {
            -webkit-animation-name: decale;
            -webkit-animation-fill-mode: forwards;
        }

        @-webkit-keyframes decale {
            0% {
                top: 0;
            }
            100% {
                top: -40px;
            }
        }

新代码

        :host /deep/ .decale {
            -webkit-animation-name: decale;
            -webkit-animation-fill-mode: forwards;
        }

        @-webkit-keyframes decale {
            0% {
                top: 0;
            }
            100% {
                top: -40px;
            }
        }

它似乎不适用于动画,或者我必须做额外的工作才能让它工作......有什么想法吗?其他解决方案?干杯!

更新

我在 bitbucket here 上托管了一些代码

on that commit我用is风格创建了一个孩子。如果您加载页面,您将看到动画

on this one我把child el放到他的parent里面,把style代码移到parent里面。孩子表现得像没有风格

and the last one除动画外的所有风格作品

克隆 repo 并使用 'pub get' 和 'pub serve' 来查看动画

【问题讨论】:

  • 嗯,我看到了一些带有 body /deep/ .my-class{...} 的例子,我会试试...
  • 你好,可以分享一下你的模板代码,让我更好地帮助你吗?

标签: polymer dart-polymer custom-element


【解决方案1】:

我不认为:host可以这样使用。

这应该可行。

    * /deep/ .decale {
        -webkit-animation-name: decale;
        -webkit-animation-fill-mode: forwards;
    }

    @-webkit-keyframes decale {
        0% {
            top: 0;
        }
        100% {
            top: -40px;
        }
    }

【讨论】:

  • 嗨,我没有尝试过这个……但它不起作用。新年快乐;)
  • 没有* /deep/.decale01 怎么样?
  • 不,由于影子 DOM,它不起作用。我需要一些能让我通过的东西。
  • 您的问题并未显示您如何使用影子 DOM。你能添加一些代码吗?
  • 您的子元素不包含类decale01 的元素。这个动画应该应用在哪个标签上?也许我错过了什么,我还没有使用 CSS 关键帧动画。
猜你喜欢
  • 1970-01-01
  • 2014-09-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-10
  • 2017-10-04
  • 1970-01-01
相关资源
最近更新 更多