开发者

jQuery effect, animation and CSS

I am trying you get a smooth jquery animate (expand dive smooth with animation like fade-in/out ) effect on mouse hover.

I have done this using css on green layer in below code but not able to implement Jquery smooth animation effect as i mention above lines.

Here is my simple code.

<!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>Untitled Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<style>
.box1{
        width:40px;
        height:13px;
        float:left;
        font-size:.6em; color:#fff; background:#99CC00;
        font-family:Arial, Helvetica, sans-serif;
        z-index:1;
        overflow:hidden;
    }
.box1:hover{
                width:200px;
                float:left;
                height:125px;
                z-index:99999999;
                position:relative;
                cursor:default;
                opacity:.8;
                filter: alpha(opacity=75);
                overflow:visible;
                }   
.box2{
        width:40px;
        height:auto;
        float:left;
        font-size:.6em; color:#fff; background:#FF6600;
        font-family:Arial, Helvetica, sans-serif;
        margin-top:1px;
        opacity:.8;
        filter: alpha(opacity=75);


    }
.box2:hover{
                width:200px;
                float:left;
                height:125px;
                position:relative;

                }   

</style>




</head>

<body>
<table width="160" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="40" height="40" valign="top" bgcolor="#e4e4e4">
        <table width="40" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><开发者_JAVA百科;div style="width:40px; height:auto; float:left; position:absolute;">
        <span class="box1">Hello <ul><li>Sanket</li><li>Pratp</li><li>Deora</li></ul></span>
</div>
</td>
  </tr>
  <tr>
    <td><div style="width:40px; height:auto; float:left; position:absolute; top:21px;"><span class="box2">Sanket</span></div></td>
  </tr>
  <tr>
    <td></td>
  </tr>
</table>

    </td>
    <td width="40" height="40" valign="top" bgcolor="#CCCCCC">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#999999">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#666666">&nbsp;</td>
  </tr>
  <tr>
    <td width="40" height="40" valign="top" bgcolor="#666666">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#999999">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#CCCCCC">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#E4E4E4">&nbsp;</td>
  </tr>
  <tr>
    <td width="40" height="40" valign="top" bgcolor="#E4E4E4">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#CCCCCC">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#999999">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#666666">&nbsp;</td>
  </tr>
  <tr>
    <td width="40" height="40" valign="top" bgcolor="#666666">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#999999">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#CCCCCC">&nbsp;</td>
    <td width="40" height="40" valign="top" bgcolor="#E4E4E4">&nbsp;</td>
  </tr>
</table>
</body>
</html>

I am new to jquery, help much appreciated.


Your question is pretty similar to this one: jQuery.animate() with css class only, without explicit styles

Or you can simply use this plugin: http://code.google.com/p/jq-class-anim/


You can do lyk dis ...just an example to explain things

 $(function() {
            $('your-dom-element').hover(function() {

                   $(this).stop().css({ 'z-index': '999999', 'position': 'absolute', 'float': 'left', 'border': 'dotted 5px black' }).animate({ marginTop: '-110px', marginLeft: '-110px', top: '20%', left: '10%', width: '700%', height: '400%', padding: '20px' }, 200, 'swing');


                }, function() {

                    $(this).stop().css({ 'z-index': '0', 'border': '0px' }).fadeIn('slow').animate({ marginTop: '0', marginLeft: '0', top: '0', left: '0', width: '100px', height: '100px', padding: '5px' }, 200, 'swing');


                });
            });


$("#element").hover(function(){
    $("#div")
    .animate({height: x + "px"}, 500);
    });

Feel free to see a version of it in a recent project (adult site), just click on search:

fuckedapps.com

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜