源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

jQuery实现字体颜色渐变效果的方法

  • 时间:2020-12-02 18:52 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:jQuery实现字体颜色渐变效果的方法
本文实例讲述了jQuery实现字体颜色渐变效果的方法。分享给大家供大家参考,具体如下: jQuery不允许css属性值为非数字的属性进行动画处理, 比如.animate(color:'red',500)或是.animate(fontWeight:'bold',500)都无法运行, 因此如果想实现颜色渐变的效果需要animate()外的其他方法,示例如下 [b]方法1:[/b]
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script type="text/javascript" src="http://libs.baidu.com/jquery/1.7.2/jquery.js"></script>
</head>
<body>
  <div class="b1" style="font-size: 50px;font-weight: bold;position: absolute;">BBB</div>
  <div class="b2" style="font-size: 50px;font-weight: bold;position: absolute;color: #f60;display: none;">BBB</div>
</body>
<script type="text/javascript">
$(function(){
  $('.b1').hover(function(){
    $('.b2').fadeIn(500);
  })
})
</script>
</html>
设置一个和b1完全相同位置的b2并隐藏,添加hover事件使b2渐显,用这个笨方法可模拟color渐变效果 [b]方法2:[/b]
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style type="text/css">
  div{
    color: red;
    transition: color 1s;
  }
  div:hover{
    color: yellow;
  }
  </style>
  <script type="text/javascript" src="d:/jquery-3.1.0.js"></script>
</head>
<body>
<div class="wrapper">1111</div>
<script type="text/javascript">
</script>
</body>
</html>

利用css3的transition方法,实现鼠标悬浮后,颜色渐变动画效果 [b]PS:这里再为大家推荐几款相关的颜色与特效工具供大家参考使用:[/b] [b]在线特效文字/彩色文字生成工具: [/b][url=http://tools.jb51.net/aideddesign/colortext]http://tools.jb51.net/aideddesign/colortext[/url] [b]在线彩虹文字/颜色渐变文字生成工具: [/b][url=http://tools.jb51.net/aideddesign/txt_caihongzi]http://tools.jb51.net/aideddesign/txt_caihongzi[/url] [b]在线发光字生成工具: [/b][url=http://tools.jb51.net/aideddesign/txt_faguangzi]http://tools.jb51.net/aideddesign/txt_faguangzi[/url] [b]仿古书排版文字竖排转换工具: [/b][url=http://tools.jb51.net/transcoding/shupai]http://tools.jb51.net/transcoding/shupai[/url] 更多关于jQuery相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/200.htm]jQuery常用插件及用法总结[/url]》、《[url=http://www.1sucai.cn/Special/93.htm]jquery中Ajax用法总结[/url]》、《[url=http://www.1sucai.cn/Special/539.htm]jQuery表格(table)操作技巧汇总[/url]》、《[url=http://www.1sucai.cn/Special/451.htm]jQuery扩展技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/430.htm]jQuery常见经典特效汇总[/url]》及《[url=http://www.1sucai.cn/Special/75.htm]jquery选择器用法总结[/url]》 希望本文所述对大家jQuery程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部