【发布时间】:2016-08-03 10:19:54
【问题描述】:
从 0 到 1 的过渡不透明度不起作用。这是我的代码:https://jsfiddle.net/ax4aLhjq/19/
//html
<div id="a">
<div style="height:20px"></div>
</div>
//css
#a{
width:200px;
background-color:salmon;
margin:0px;
padding:0px;
height:200px;
overflow: auto;
}
#a .item{
margin:0px 5px;
background-color:teal;
padding:10px;
color:white;
opacity:0;
transition:opacity .5s ease-in-out;
}
//js
function add(){
var div = document.createElement("div");
div.className ="item";
var newtext = document.createTextNode("aa");
div.appendChild(newtext);
document.querySelector("#a").appendChild(div);
var separator = document.createElement("div");
separator.style.height="10px";
document.querySelector("#a").appendChild(separator);
//apply opacity
div.style.opacity=1;
}
setInterval(add,3000);
我是不是做错了什么?
【问题讨论】:
-
不透明度从 0 到 1,而不是 100。
-
谢谢。我已经更新了帖子,但问题仍然存在。
标签: javascript html css