HTML源码

如何用css或者js实现当鼠标移动到上面,出现另一张图片,而原图片依然在它的下面。(也就是,当鼠标移动到上面,出现一层水印效果)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>水印测试</title>
<style>
.div{
  position:relative;
  width:300px;
  height:300px;
  background:url(img/1.jpg) no-repeat left top;
  background-size:100%;
  
}
.div .ico{
  width:100px;
  height:100px;
  position:absolute;
  right:10px;
  bottom:10px;
  display:none;
  background:url(img/1.png) no-repeat left top;
  background-size:100px;
}
.div:hover .ico{
  display:block;
}
</style>
</head>

<body>
<div class="div">
     <div class="ico"></div>
    </div>
</body>
</html>


这个是用纯css实现的,换成图片一个道理。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-01-07
<head>
    <style>
        .show   
        {
            z-index=99;
        }
        .hide
        {
            z-index=-999;
            display=none;
        }
        .show .hide
        {
            top:0;
            left:0;
            position:absolute;
        }
    </style>
</head>
<body>
    <img src=... class="show"/>
    <img src=... class="hide"/>
    <script>
        var oImg=document.getElementsByTagName("img");
        oImg[0].onmouseover=function showIt()
        {
            oImg[1].style.display="inline";
            oImg[1].style.zIndex=100;
            oImg[1].style.opacity=...;        //设置透明度
        }
    </script>
</body>

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网