CSS过渡鼠标离开不正常

时间:2015-04-16 12:42:01

标签: css3 transition

我正在尝试缩放并调低图像的不透明度,当我使用光标进入img但是当我离开img过渡时,它真的很棒。

这是我的代码:

#hoverCon:hover img {
  transform: scale(1.2);
  opacity: 0.5;
  transition: all .28s ease-out;
}

1 个答案:

答案 0 :(得分:2)

你应该写

#hoverCon img {
  transform  : scale(1);   /* optional */
  opacity    : 1;          /* optional */
  transition : all .28s ease-out;
}

#hoverCon:hover img {
  transform  : scale(1.2);
  opacity    : 0.5;
}

定义基本属性(可选)并在正常状态下转换,然后仅更改hover

上的属性

示例:http://codepen.io/anon/pen/JogVVW