【发布时间】:2013-06-14 11:12:48
【问题描述】:
我正在尝试创建自己的垂直进度条,并正在考虑通过 CSS3 对其进行动画处理。我目前已将其设置为角度指令,点击后,它应该更改内部 div 的高度属性。但是,当我 console.log(element.children().css('height')) 时,它返回给我一个空白值,即使我已经将初始高度设置为 10%?
angular.js 指令
teacherApp.directive('clickToChangeHeight', function(){
return {
link: function(scope, element, attrs) {
element.bind('click', function() {
var height = element.children().css('height');
console.log(height)
//element.children().css('height', finalHeight);
});
}
}
})
玉标记
div(ng-controller='TvCtrl')
.outer(click-to-change-height)
.inner
CSS
.outer {
position: relative;
overflow: hidden;
width: 30px;
height: 140px;
border: 2px solid #ccc;
}
.inner {
position: absolute;
overflow: hidden;
bottom: 0;
width: 100%;
height: 10%;
background-color: #999;
-webkit-transition: height 2s;
}
【问题讨论】: