【发布时间】:2016-01-21 00:10:06
【问题描述】:
我正在尝试在单击 FAB 按钮时对其进行动画处理。我希望它打开并填满屏幕 - 它适用于在移动设备中运行的响应式 webApp。
问题是:当我点击打开按钮时,它会立即获得全宽然后动画。而要关闭按钮,它会立即缩短,然后向下动画。
问题是我用的是固定位置,所以不知道怎么处理。
这是一个代码示例:
html:
<div class="fab" ng-class="{'open': fabOpen}" ng-click="toggleFab()">
<span ng-show="!fabOpen">FAB</span>
<h4 ng-show="fabOpen">Just a test</h4>
</div>
scss:
$time: 400ms;
.fab {
-webkit-transition-duration: $time;
-moz-transition-duration: $time;
-o-transition-duration: $time;
transition-duration: $time;
border-radius:50%;
background:#358FE8;
display:inline-block;
height:80px;
line-height:80px;
width:80px;
position:fixed;
bottom:16px;
right:16px;
text-align:center;
cursor:pointer;
color:white;
&.open {
background:#fff;
color:black;
border:1px solid #eee;
border-radius:2px;
left: 16px;
width:auto;
height:90%;
}
}
这是问题的现场演示:http://jsfiddle.net/tfrxf0p5/
【问题讨论】:
-
愿望是什么?等间隔扩大高度和宽度?
-
@leigero 不需要完全完美。但是正如您在演示中看到的那样,打开时,宽度为全角,没有动画,关闭时也是如此。我希望它是平滑的,而不是突然的!
标签: css button css-animations floating-action-button