English 中文(简体)
您能否改变CSS3线关键方位特征(即超文本字体特性)?
原标题:Can you change CSS3 animation keyframe attributes inline (i.e. in the HTML style attribute)?

有可能通过进行线性调整来改变估算的关键参数。

例如

@-moz-keyframes slidein {
    from {
        width: 10%;
    }

    to {
        width:50%;
    }
}

有可能将主力部分的宽度改变为主力部分,例如做一些事情。

<div id="someID" style="change keyframe here">

目前,我只是动态地在网页上打上整个风格,以便定制钥匙。

然而,这一方法可以发挥作用,但我会在很大程度上调整简化的属性。

最佳回答

No. since the animation is not reported in the content, it s only known on it. 它试图将方法添加到物体中而不是一个类别。 不可能;

问题回答

在这里,利用特别安全变量来做到这一点:

<div style="--from-width:10px; --to-width:20px; animation:slide 1s ease infinite;"></div>
@keyframes slide {
  from {
    width: var(--from-width);
  }

  to {
    width:var(--to-width);
  }
}

这显然赢得了所有案件的工作,但如果你需要在现有一套关键框架中确定一些数字,那么,它可能为你工作。

...... 你可能无法这样做......

<div id="someID" style="change keyframe here">

但想这样做......

<script>
var createdStyleTag = document.createElement("style");
createdStyleTag.textContent = "@-*whatevaVendor*-keyframes someAnimationName{"+
    "from { width: **SOMETHING YOU DECLARE THROUGH JS**; }"+
    "to{ width: 10%; }"+
"}";

document.body.appendChild(createdStyleTag);
</script>

这对你想要做什么都很开放。 ......你总是会把你们的班子放在内容上,但有时我们会想不断有同样的“从”和“到”的班子,这样就可以做到这一点。 工作良好...... 在我自己的框架内使用 我不喜欢这样做,但我写了这样的话,以引起人们的注意。 因此,以良好的方式开展这项工作,也使我的许多人力部得以生动地建立起来,因此,在执行过程中可能更有意义。

根本不可能......仅仅在四舍五入之外思考

I was searching for a solution for inline keyframe too. At least for the "to" value. CSS Tricks give a good solution, just forget the "to" and place the width inline ;) http://css-tricks.com/animate-to-an-inline-style/

This solution sounds a lot like the one you may already be implementing, but it s very well explained and thought out: Set Webkit Keyframes Values Using Javascript Variable

as @Zetura said the best way to do it is to forget the "to" property and it will take the default value of the width or height or any thing you put it to the as example for me its work :

@keyframes slideInUp {
    0% {
        height: 0px;

    }

}




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签