小编典典

如何使用JavaScript设置CSS3过渡?

css

如何使用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';

阅读 283

收藏
2020-05-16

共1个答案

小编典典

如您所见,将CSS属性设置为“-”只会导致下一个字符变为大写:

document.getElementById('fade').style.WebkitTransition = 'opacity 1s';
document.getElementById('fade').style.MozTransition = 'opacity 1s';
2020-05-16