悬停按钮时移动移动 div

Move a Moving div, when hovering a button(悬停按钮时移动移动 div)

本文介绍了悬停按钮时移动移动 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表格单元格中的(链接)按钮修复(但单击时链接不起作用.)

A (link) button fix in table cell (But link not working when clicked.)

悬停按钮时如何移动另一个移动"div?

How to move another 'Moving' div, when hovering the button?

代码:

HTML

<table cellpadding="0" cellspacing="0" border="0" width='650' height='320' style="border: 1px solid #000; position: absolute; top: 300px;">
    <tr>
        <th>
            <div class="Fly" style="position: absolute; left: 300px; top: -300px;">
                <div id="Superman"></div>
            </div>
            <div class="button" style="position: absolute; left: 80px; top: 60px;">
<a href="https://stackoverflow.com/questions/25909457/moving-div-moving-whole-page"></a>

            </div>
        </th>
    </tr>
</table>

CSS

#Superman {
    background: url(http://www.comixoasis.com/v/vspfiles/templates/runner/images/homepage/Superman.png) no-repeat;
    width:250px;
    height:300px;
    background-size: 90%;
    transition: 3s ease;
}
#Superman:hover {
    background: url(http://www.mc-villalobos.com/sources/superman.png) no-repeat;
    background-size: 100%;
    transform: translate(0, 350px);
    /*move-down*/
}
.button {
    background: url(http://iconbug.com/data/26/256/a2ccff2488d35d8ebc6189ea693cb4a0.png) no-repeat;
    width:300px;
    height:300px;
}
.button:hover {
    background: url(http://1.bp.blogspot.com/__JNFVYfijS4/SX9bD7dk07I/AAAAAAAAAXw/VJCkHGqZFx4/s400/Happy.png) no-repeat;
    width:300px;
    height:300px;
}

JS

    $(document).ready(function () {

    function moveDown() {
        $('.Fly').animate({
            'marginTop': "+=100px"
        }, 1000, moveUp)
    }

    function moveUp() {
        $('.Fly').animate({
            'marginTop': "-=100px"
        }, 1000, moveDown)
    }
    moveUp();
});

演示

推荐答案

你的 a 元素是空的:

<div class="button" style="position: absolute; left: 80px; top: 60px;">
  <a href="https://stackoverflow.com/questions/25909457/moving-div-moving-whole-page">
  </a>
</div>

div 移到其中,它应该可以工作:

Move the div inside it, and it should work:

<a href="https://stackoverflow.com/questions/25909457/moving-div-moving-whole-page">
  <div class="button" style="position: absolute; left: 80px; top: 60px;">
  </div>   
</a>

这篇关于悬停按钮时移动移动 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:悬停按钮时移动移动 div

基础教程推荐