CSS Transitions仅在等待后才起作用

时间:2014-08-24 03:42:51

标签: css angularjs css-transitions

我正在构建一个响应式Angular网站(can be viewed here)并构建了一个指令来处理我的网站标题。但是,CSS转换有一些奇怪的行为。

我将首先回顾一下应该发生的事情:

  • 当窗口调整大小低于600px时,“home”和“projects”会滑开。
  • 当您点击绿色方块时,橙色面板向下滑动,蓝色框以更浓缩的形式重新排列。
  • 当您再次点击绿色方块时,橙色面板会向上滑动,蓝色框会返回到之前的位置。

到目前为止,所有元素都在他们想要的位置,但有时候动画会起作用,有时则不会。

  • 单击以展开橙色面板从不显示动画
  • 橙色面板展开时移动蓝框的动画永远不会显示。
  • 如果用户在冷凝之前等待,橙色面板的冷凝将仅显示动画。展开面板,然后快速单击绿色方块将导致动画失败。
  • 调整大小时成功显示动画似乎是零星的。

这可能与在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;
}

由于

2 个答案:

答案 0 :(得分:0)

对于您的第一个问题,您可以将导航器的最小宽度设置为700像素或您想要的。

当你点击绿色按钮时所有按钮移动的问题是我应该做的是在标题栏下面做一个divm。所以当你点击栏上滑下来的绿色按钮时。

我希望这对你有所帮助。

答案 1 :(得分:0)

显然,目前Angular中的一个小故障会导致CSS3动画出现问题。我不清楚细微差别,但我更新它以使用声明性动画库。