css - CSS3 过渡流程问题

标签 css sass css-transitions

我在 this page 上设置了背景转换.

页面的第一个区域“Il Blog - Leggi tutti gli articoli”“Gli Eventi - Leggi tutti gli eventi”显示了不同帖子类型的列表瓷砖。 当悬停在其中之一上时,过渡开始。 当鼠标移出时,另一个过渡开始。 直到那里一切都很好。

当我在转换完成之前将鼠标移出图 block 时出现问题。

我想弄清楚我的 CSS 中缺少什么,但找不到。

我知道我可能可以解决将过渡转移到 jQuery 脚本的问题,但我更喜欢使用纯 CSS 方法。

以下是所涉及元素的 SCSS 摘录:

article {

    @include box-shadow(0 0 2px $primary-color);
    @include transition(all 1s ease-in-out);
    @include border-radius(2px);

    background-image: url('../images/concrete_wall.png');

    &:hover {
      @include box-shadow(0 0 4px $primary-color);
      background-image: url('../images/concrete_wall_2.png');

    }
}

这是生成的 CSS,以防有人喜欢这样看:

body.home #posts-area #posts-area-columns #home-posts-list article, body.home #posts-area #posts-area-columns #featured-events-list article {
  -webkit-box-shadow: 0 0 2px #222222;
  -moz-box-shadow: 0 0 2px #222222;
  box-shadow: 0 0 2px #222222;
  -webkit-transition: all 1s ease-in-out;
  -moz-transition: all 1s ease-in-out;
  -o-transition: all 1s ease-in-out;
  transition: all 1s ease-in-out;
  -webkit-border-radius: 2px;
  -moz-border-radius: 2px;
  -ms-border-radius: 2px;
  -o-border-radius: 2px;
  border-radius: 2px;
  background-image: url("../images/concrete_wall.png");
}
/* line 60, ../sass/_home.scss */
body.home #posts-area #posts-area-columns #home-posts-list article:hover, body.home #posts-area #posts-area-columns #featured-events-list article:hover {
  -webkit-box-shadow: 0 0 4px #222222;
  -moz-box-shadow: 0 0 4px #222222;
  box-shadow: 0 0 4px #222222;
  background-image: url("../images/concrete_wall_2.png");
}

最佳答案

您在悬停中包含的第二个过渡是无用的。缓入淡出使其淡入淡出。

article {

    @include box-shadow(0 0 2px $primary-color);
    @include transition(all 1s ease-in-out); //Note i changed it to eas-in-out
    @include border-radius(2px);

    background-image: url('../images/concrete_wall.png');

    &:hover {
      @include box-shadow(0 0 4px $primary-color);
      background-image: url('../images/concrete_wall_2.png');
      //Note I removed the unnecessary transition
    }
}

关于css - CSS3 过渡流程问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16541620/

相关文章:

html - 使用@font-face 时 firefox 和 IE 中的负上边距

html - Bootstrap 根据移动布局更改 css

html - 第一个 child 未触发

css - 为什么我的自定义 CSS 片段不起作用?

html - CSS - 调用 element[attribute^=value] 后未应用 border-X-color 的原因

javascript - 顺风 CSS 导航栏

html - SCSS 引用元素的特定实例

css - Edge 中的 rotateY() 与 matrix3d 转换

CSS :after hover Transition

CSS 元素过渡高度不适用于 chrome