css3 - react 组件设置的 transform 无效
高洛峰
高洛峰 2017-04-17 11:59:45
0
3
868
JSX:
style={this.state.expand == index ? {transform: 'rotate(180deg)', backgroundColor: 'black'} : null}

有背景色效果,无旋转样式(chrome)
假如写在样式表上,class没有动态更新的可以有样式
会是组件生命周期问题?

补充的图片@michael_cai
@michael_cai:
我换了一种方式,写在行间也是不行,浏览器显示的样式表上也有

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
大家讲道理

This has nothing to do with react.

You will know if the style sheet of the element you are operating contains the style you want.

In fact, what you are doing here is simply adding a class to the dom element. As long as the dom element has this class, it means that your react writing method is fine. It may only be a style problem.

洪涛

It really has nothing to do with react,

It’s just because your attribute is missing transition, an important attribute of css3 animation.

transition: all 2s ease;
语法
transition: property duration timing-function delay;
           属性的名称 时长  动画方法 延迟

Document portal: http://www.w3school.com.cn/cs...

迷茫

Later I found out that transform is not valid on inline elements. Thank you for your answers!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template