如何使用javascript设置CSS3转换? [英] How to set CSS3 transition using javascript?

查看:111
本文介绍了如何使用javascript设置CSS3转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用javascript设置CSS(我没有访问CSS文件)?

How can I set CSS using javascript (I don't have access to the CSS file)?

#fade div {
  -webkit-transition: opacity 1s;
  -moz-transition: opacity 1s;
  -o-transition: opacity 1s;
  -ms-transition: opacity 1s;       
  transition: opacity 1s;
  opacity: 0;
  position: absolute;
  height: 500px;
  width: 960px;
}

例如:

document.getElementById('fade').HOW-TO-TYPE-webkit-transition = 'opacity 1s';


推荐答案

您应该看这里: http://www.javascriptkit.com/javatutors/setcss3properties.shtml

您可以看到用 - 设置CSS属性只会导致下一个字符为资本:

As you can see setting CSS Properties with "-" just results in the next character to be capital:

document.getElementById('fade').style.WebkitTransition = 'opacity 1s';
document.getElementById('fade').style.MozTransition = 'opacity 1s';

这篇关于如何使用javascript设置CSS3转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆