如何使用javascript设置CSS(我无权访问CSS文件)?
#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';
如您所见,将CSS属性设置为“-”只会导致下一个字符变为大写:
document.getElementById('fade').style.WebkitTransition = 'opacity 1s'; document.getElementById('fade').style.MozTransition = 'opacity 1s';