【发布时间】:2015-07-04 22:05:40
【问题描述】:
我正在尝试为 div 的字体大小设置动画,将其减小到 0px。 这是我的尝试: http://jsfiddle.net/corington/15gw9Lxq/1/
HTML:
<button id="roll">Go</button>
<div id="screen">
<div id="rolled" class="vert">12</div>
</div>
CSS:
.vert {
position: relative;
top: 50%;
transform: translateY(-50%);
}
#screen {
display:none;
position:fixed;
padding:0;
margin:0;
top:0;
left:0;
z-index: 100;
width: 100%;
height: 100%;
}
#rolled {
font-size: 150px;
text-align: center;
color:#ccc;
font-weight:bold;
}
脚本:
$("#roll").click(function(){
// display rolled
$("#screen").css("display", "block");
// animate rolled
var poscss = "{'fontSize' : '0px'};";
$("#rolled").animate(
poscss,
"slow",
"swing",
function() {
$("#screen").css("display", "none");
}
);
});
似乎可以正常调用 animate 函数,但没有任何反应。有小费吗? 谢谢 科林
【问题讨论】: