css - `ng-hide` - 动画如何防止隐藏时跳转?

标签 css angularjs

我正在尝试通过面板高度使用 ng-hide 制作 Accordion 动画。但是我在应用 ng-hide 时发现了一个跳跃。 (点击第一个标题显示和隐藏)

有人帮我解决这个问题吗?

这是我的 CSS 代码:

.animate-show{
  border:2px solid gray;
  padding: 10px;
  background:green;
}

.animate-show.ng-hide {
  transition: all linear 0.5s;
}

.animate-show.ng-hide {
  line-height: 0;
  padding: 0;
  height:0;

}

Live Demo

最佳答案

您需要移除 .animate-show.ng-hide 类中绿色内容 div 和后续切换 div 之间的边距。您可以通过为此类设置负 margin-bottom 样式来做到这一点:

h1{
  background:gray;
  cursor:pointer;
}

.animate-show{
  border:2px solid gray;
  padding: 10px;
  background:green;
  overflow:hidden;
}

.animate-show.ng-hide-add{
  transition: all linear 0.5s;
}

.animate-show.ng-hide-remove
{
  transition: all linear 0.5s;
}


.animate-show.ng-hide {
  line-height: 0;
  padding: 0;
  height:0;
  margin-bottom:-21px;
}

这是 Plunker:http://plnkr.co/edit/XQ4p8uE47QxQbDKUiIyi?p=preview

关于css - `ng-hide` - 动画如何防止隐藏时跳转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37460114/

相关文章:

jquery - 自定义 jquery ui 进度条

javascript - Angular Schema 表单从 JSON 加载数据

javascript - 如何重新加载 AngularJS 部分模板?

javascript - window.onbeforeunload 自定义消息上的返回消息未设置。它总是显示默认消息

javascript - 用 angular.element 注册的事件是否会被 $destroy 删除?

html - CSS 在 IE9 中显示不正确

css - 额外的像素被添加到我的行高

css - 复杂选择器在最后一个闪烁版本 :nth-child(2):nth-last-child(2){} 中不起作用

javascript - Chrome 和 IE 上的 html 表格并排问题

javascript - 使用 ng-grid 单元格值中的值在 SharePoint 模式中打开链接