鼠标经过图片由灰色变彩色

来源:互联网 发布:八爪鱼大数据 编辑:程序博客网 时间:2024/04/28 03:56

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS 图片由灰色变彩色</title>
<style type="text/css">
*{margin:0;padding:0;}
img{border:0;}
#container{margin:20px auto;width:960px;overflow:hidden;}
#frmsearch{margin:0 auto;width:345px;height:142px;overflow:hidden;}
#frmsearch h2{margin:0 auto;width:100%;height:23px;line-height:23px;overflow:hidden;text-indent:-9999px;font-size:14px;color:#FFF;}
#frmsearch input{float:left;width:290px;height:22px;margin:24px 25px 0 30px;display:inline;border:0;}
#frmsearch button{float:left;width:70px;height:27px;margin:29px 0 0 250px;cursor:pointer;display:inline;text-indent:-9999px;clear:both;border:0;background:none;}
.frmsearch-normal{background:url(/jscss/demoimg/200908/sprites.gif) 0 0 no-repeat;}
.frmsearch-active{background:url(/jscss/demoimg/200908/sprites.gif) 0 -142px no-repeat;}
</style>
</head>
<body>
<div id="container">
<form name="frmsearch" class="frmsearch-normal" id="frmsearch" action="" metod="post">
<h2>查找</h2>
<input type="text" id="keyword" value="" /> 
<button type="submit" id="btnsearch">查找</button>
</form>
</div>

<script type="text/javascript">
(function(){
 var D = document, frm = D.getElementById('frmsearch');
 if(!frm){
  return false;
 }
 frm.onmouseover = function(){
  this.className = 'frmsearch-active';
 };
 frm.onmouseout = function(){
  this.className = 'frmsearch-normal';
 };
})();
</script>
</body>
</html>

原创粉丝点击