最近在浏览网页时,看到一些图片,鼠标一放上去呢,就会有说明文字“浮”上来,移开又“沉”下去,感受好炫!本身就在网上找实现代码啊,看看事件是怎么实现的!而后就找到了以下的代码:javascript
恩呢,放在编译器里,的确有效果,的确是我想象中的那样,但是,我本身感受写的太复杂了,挺简单的一个问题对吧?而后就本身写了,刚开始有点小问题,不知道怎么实现那个上浮效果,最后想到了overflow这个属性,写出了如下代码:css
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="content-type" content="txex/html charset=utf-8" >
- <script src="jquery-1.11.1.js"></script>
- <style type="text/css">
- body{
-
- font-family: simhei;
- }
- p{
- color: #ffffff;
- }
- div{
- overflow: hidden;
- }
- </style>
- <script type="text/javascript">
- $(document).ready(function(){
-
- $(".pic").mouseover(function()
-
-
- { $(".he").animate({top:'280px'},500);})
-
- $(".pic").mouseout(function()
-
- {$(".he").animate({top:'330px'},500);}
- )
- });
- </script>
- </head>
- <body>
- <div style="position: relative">
- <img src="test.png" class="pic">
- <div style="width:231px;height: 50px;background-color: orange;position: absolute;top:330px" class="he">
- <p align="center" >开始答题</p>
- </div>
- </div>
- </body>
- </html>