【发布时间】:2014-08-25 08:25:13
【问题描述】:
我正在构建一个响应式 Angular 网站 (can be viewed here) 并构建了一个指令来处理我网站的标题。但是,CSS 转换有一些奇怪的行为。
我将首先回顾一下应该发生的事情:
- 当窗口大小调整到 600 像素以下时,“主页”和“项目”会滑开。
- 当您单击绿色方块时,橙色面板会向下滑动,蓝色框会以更简洁的形式重新排列。
- 当您再次单击绿色方块时,橙色面板会向上滑动,蓝色框会返回到之前的位置。
到最后,所有元素都在他们想要的位置,但有时动画有效,有时则无效。
- 点击展开橙色面板从不显示动画
- 从不显示橙色面板展开时移动蓝色框的动画。
- 仅当用户在压缩之前等待时,压缩橙色面板才会显示动画。展开面板,然后快速点击绿色方块会导致动画失败。
- 调整大小时动画的成功显示似乎是零星的。
这可能与 Angular 指令中应用范围更新的方式有关,但我认为这可能与 CSS 过渡有关,因为它们仍处于试验阶段。以下是我的这个标题的 CSS:
#headerDiv {
position: absolute;
top: 0px;
left: 0px;
right: 0px;
background-color: orange;
z-index: 100;
overflow: hidden;
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-ms-transition: all 600ms ease;
transition: all 600ms ease;
}
.headerUnexpanded {
height: 50px;
}
.headerExpanded {
height: 150px;
}
#headerCenter {
position: absolute;
top: 0px;
bottom: 0px;
left: 50%;
right: 50%;
overflow: visible;
}
#headerIcon {
margin: auto;
position: absolute;
left: 0;
bottom: 5px;
right: 0;
width: 40px;
height: 40px;
background-color: green;
}
#headerHome {
margin: auto;
position: absolute;
width: 100px;
height: 40px;
background-color: blue;
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-ms-transition: all 600ms ease;
transition: all 600ms ease;
}
#headerHome.here {
top: 5px;
right: 175px;
}
#headerHome.gone {
top: 5px;
right: 300px;
}
#headerHome.expand {
top: 55px;
right: 50px;
}
#headerProjects {
margin: auto;
position: absolute;
width: 100px;
height: 40px;
background-color: blue;
-webkit-transition: all 600ms ease;
-moz-transition: all 600ms ease;
-ms-transition: all 600ms ease;
transition: all 600ms ease;
}
#headerProjects.here {
top: 5px;
left: 175px;
}
#headerProjects.gone {
top: 5px;
left: 300px;
}
#headerProjects.expand {
top: 55px;
left: 50px;
}
#headerResume {
position: absolute;
top: 5px;
bottom: 0;
right: 50px;
width: 100px;
height: 40px;
background-color: blue;
}
#headerContact {
position: absolute;
top: 5px;
bottom: 0;
left: 50px;
width: 100px;
height: 40px;
background-color: blue;
}
谢谢
【问题讨论】:
-
你能展示你的javascript代码吗? CSS 过渡中没有任何东西看起来乱七八糟。
-
指向页面的链接或 jsFiddle 也不会受到伤害,因此我们可以使用一些浏览器开发工具来检查代码
标签: css angularjs css-transitions