javascript - js如何实现文字颜色渐变
PHP中文网
PHP中文网 2017-04-10 12:43:22
0
3
1097

javascript如何实现鼠标hover链接,链接字体颜色渐变?

PHP中文网
PHP中文网

认证高级PHP讲师

全部回复 (3)
Peter_Zhu

修正:
第一次没有仔细读官方文档,jQuery 原生不支持 color 的 animate,因为 color 的值不是数字。谢谢 @airyland 及 @冰剑 的纠正。

All animated properties should be animated to a single numeric value, except as noted below; most properties that are non-numeric cannot be animated using basic jQuery functionality(For example, width, height, or left can be animated but background-color cannot be, unless the jQuery.Color() plugin is used). Property values are treated as a number of pixels unless otherwise specified. The units em and % can be specified where applicable.

让 animate 支持 color,有以下三种方法:
1. 引入 jQuery UI
2. 引入 jQuery color
3. 引入 jQuery color animation

可以使用 jQuery 提供的 animate 方法,具体参考:http://api.jquery.com/animate/

比如本页面上作者名链接,简单示例:

$('.post-author a').on('hover', function(){ $(this).animate({ color: '#ffffff'}, 5000) })
    阿神

    如果浏览器支持,可以用CSS3中的transition,而不用javascript实现,只需要简单的几条css声明。

      Peter_Zhu

      答案不靠谱

        最新下载
        更多>
        网站特效
        网站源码
        网站素材
        前端模板
        关于我们 免责声明 Sitemap
        PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!