javascript - 过渡不适用

标签 javascript jquery html css

所以我使用 jQuery 来更改图标,并使用 CSS 来应用转换。由于某种原因,它不起作用这是我的代码

CSS

.fa-heart{
  transition: 1s;
}
.fa-heart-o{
  transition: 1s;
}

JS

$('.fa-heart-o').hover(function() {
     $(this).toggleClass('fa-heart-o fa-heart');   
}, function() {
     $(this).toggleClass('fa-heart-o fa-heart'); 
});

演示 http://jsfiddle.net/cLVBg/1/有任何想法吗?

最佳答案

content 不是 animatable property ,因此 transition 不适用。但是,如果您只想用不透明度的过渡来填充心脏,请尝试使用 SVG - 或 CSS-创建心脏,或者只是将一个放在另一个之上并改变它们的不透明度值。

示例:http://jsfiddle.net/cLVBg/5/

关于javascript - 过渡不适用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24536758/

相关文章:

javascript - 如何向 html5 视频播放器添加搜索 slider ?

html - 边框不覆盖图片

php - 将mysql信息动态放置在带有id的div中

javascript - CSS 问题毫无意义

javascript - 如何将具有背景的 <span> 定位到中心?

javascript - 将 ngCsv 与外部 API 结合使用

javascript - ajax php 中单选按钮 undefined index 值

javascript - 如何使用 jQuery 更改背景图像

jquery - 无法从带注释的 Controller 获取自动格式化的 json 数据

javascript - 在下拉菜单中响应地隐藏和显示子元素