【问题标题】:CSS Transitions works only after waitingCSS 过渡仅在等待后才起作用
【发布时间】: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


【解决方案1】:

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

当您单击绿色按钮时所有按钮都移动的问题我应该做的是在标题栏下方创建一个 divm。因此,当您单击绿色按钮时,该栏会向下滑动。

我希望这对你有更多帮助。

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 你有这方面的资料吗?我遇到了类似的问题,正在尝试研究它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    • 2012-09-27
    • 2013-10-22
    相关资源
    最近更新 更多