简体   繁体   English

如何向下滑动外部div,同时向下滑动内部内容(最初是隐藏的)?

[英]How do I slide down outer div while also sliding down inner contents (initially hidden)?

I have a div containing three images. 我有一个包含三个图像的div。 I want to slide down the div on hover (which is working correctly). 我想将鼠标悬停在div上(它可以正常工作)。 However, while the outer div slides down, the images are not sliding down. 但是,当外部div向下滑动时,图像不会向下滑动。 Instead, they are being exposed incrementally (not moving) as the outer div slides down. 相反,它们随着外部div向下滑动而逐渐暴露(不移动)。

How can I get the outer div to slide down and make the images slide down (moving downward) initially from their hidden position as opposed to being incrementally displayed and not moving at all? 如何使外部div向下滑动,并使图像最初从其隐藏位置向下滑动(向下移动),而不是逐渐显示而不是完全不移动?

CSS CSS

div.Game {width: 100%; height: 500px; border: solid 1px}
div.options { height: 30px; position:relative; display: none; background-color: #f3f3f3; z-index: 3; width: 100% }
div.options div {display: inline-block}
div.options img {z-index: 4; max-height: 30px}
div.shadow img {max-height: 5px; width: 100%}
div.shadow {display: block !important}
div.wrapper {display: block; position: relative; width: 100%; overflow: hidden}

HTML HTML

  <div class="Game">
        <div class="wrapper">
                 <div class="options">
                     <div style="float:left; margin-left: 10px; margin-right: 10px"><a class="move"><img src="http://www.imagesup.net/di-3142084693010.png"/></a></div>
                <div style="float:right; margin-left: 10px; margin-right: 10px"><a class="resize"><img src="http://www.imagesup.net/di-15142084696415.png"/></a></div>
                <div style="float:right; margin-left: 10px; margin-right: 10px"><a class="remove"><img src="http://www.imagesup.net/di-214208466443.png"/></a></div>
                </div>
                <div class="shadow">
                <img src="http://www.imagesup.net/di-1114208466444.png" />
                </div>
            </div>
    </div>

JS JS

        $("div.Game").hover(function () {
           $("div.options").slideDown("fast");
        }, function () {
            $(this).find("div.options").slideUp("fast");
        });

http://jsfiddle.net/496c0qp7/9/ http://jsfiddle.net/496c0qp7/9/

EDIT 编辑

After some searching I found an example close to what I am trying to make happen. 经过一番搜索,我找到了一个与我要实现的目标接近的示例。 It uses animate instead of slide method. 它使用动画代替幻灯片方法。 I will post an updated fiddle of my provided code. 我将发布我提供的代码的更新小提琴。

jquery animate down (100% element height) jQuery动画向下(100%元素高度)

http://jsfiddle.net/7dary/1/ http://jsfiddle.net/7dary/1/

http://jsfiddle.net/MattLo/7dary/2/ http://jsfiddle.net/MattLo/7dary/2/

I am not sure if I fully understand what you are asking for, but I will give it a shot. 我不确定我是否完全理解您的要求,但是我会试一试。

I added a couple things to the jQuery: 我向jQuery添加了几件事:

$("div.Game").hover(function () {
    $("div.options, div.options *").slideDown("fast");
}, function () {
    $(this).find("div.options, div.options *").slideUp("fast");
});

Example here: http://jsfiddle.net/bjogden/496c0qp7/10/ 此处的示例: http : //jsfiddle.net/bjogden/496c0qp7/10/

Like I said, I don't fully understand what you are asking for, so if this isn't right, I'll give it another go. 就像我说的那样,我不太了解您的要求,因此,如果这不正确,我会再考虑一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM