简体   繁体   English

使第二个 div 从上到下滑动

[英]To make the second div slide from top to bottom

I am working on hide and show functionality.我正在研究隐藏和显示功能。 I have one bug in my code;我的代码中有一个错误; when I click the first div, the content is opening from down to top, whereas when I click the second div it opens from right to left.当我单击第一个 div 时,内容从下到上打开,而当我单击第二个 div 时,它从右到左打开。 It should open from top to bottom.它应该从上到下打开。 How to fix it?如何解决?

Providing my code below:在下面提供我的代码:

http://jsfiddle.net/2syzQ/45/ http://jsfiddle.net/2syzQ/45/

 <div id='firstRadio'>
        <div class="first" > First </div>
        <div class="arrow-down"></div>
    </div>


$(document).ready(function() {
    $("#firstRadio").click(function() {
        $("#secondHiddenDiv").hide("slow");
        $("#firstHiddenDiv").show("slow");
    });
    $("#secondRadio").click(function() {
        $("#firstHiddenDiv").hide("slow");
        $("#secondHiddenDiv").show("slow");
    });
    $("#thirdRadio").click(function() {
        $("#firstHiddenDiv, #secondHiddenDiv").hide("slow"); 
    });
});

I`ve made some changes to your HTML structure.我已经对您的 HTML 结构进行了一些更改。

You can see the update here: http://jsfiddle.net/2syzQ/51/你可以在这里看到更新:http: //jsfiddle.net/2syzQ/51/

HTML: HTML:

<div class="first" id='firstRadio'> 
    First 
    <div id='firstHiddenDiv'>
        <div class="arrow-down"></div>
       Text
    </div>
</div>
<div class="second" id='secondRadio'> 
    Second 
    <div id='secondHiddenDiv'>
        <div class="arrow-down"></div>
        Text
    </div>
</div>

For the CSS:对于 CSS:

#container > div { position: relative; } 
.first > div, .second > div { position: absolute; top: 20px; left: 0; }

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

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