style
声明一个包含 CSS 属性/样式的键值对象,可在动画序列中用作动画状态(state
),或在调用 animate()
和 keyframes()
时作为传入的样式数据。
Declares a key/value object containing CSS properties/styles that can then be used for an animation state
, within an animation sequence
, or as styling data for calls to animate()
and keyframes()
.
style(tokens: "*" | { [key: string]: string | number; } | ("*" | { [key: string]: string | number; })[]): AnimationStyleMetadata
参数
返回值
一个封装了样式数据的对象。
AnimationStyleMetadata
: An object that encapsulates the style data.
使用说明
下面的例子创建了一些带有一组 CSS 属性值的动画样式:
The following examples create animation styles that collect a set of CSS property values:
// string values for CSS properties
style({ background: "red", color: "blue" })
// numerical pixel values
style({ width: 100, height: 0 })
下面的例子使用了自动样式,以允许此动画将组件的高度从 0 逐渐增长到其父元素的高度:
The following example uses auto-styling to allow a component to animate from a height of 0 up to the height of the parent element:
style({ height: 0 }),
animate("1s", style({ height: "*" }))