1

I have 2 small divs, side by side in a bigger div, display flex. I want one of the small divs to appear by sliding up, and the other by sliding down. They both work fine when sliding down, but when I change one to slide up, it doesn't show the div.

I've tried position:relative, also in jQuery using the hide() and show() functions instead of just display: none in my css. But I know that the display:none in css works fine with the sliding down, so I just Don't get it!

   <div class="nousEtMission">
        <div id="quiSommesNous"> TEST 1
        </div>
        <div id="mission"> TEST 2
        </div>
    </div>

<script>

        $(document).ready(function () {
        $("#header").fadeIn(1500);
        $("#quiSommesNous").slideUp(3000);
        $("#mission").slideDown(3000);
</script>

.nousEtMission{
    display: flex;
    justify-content: space-evenly;
    height: 30vh;
}

#quiSommesNous{
    display: none;
    position: relative;
    background-color: rgb(123, 216, 35);
    width: 50%;
}

#mission{
    display: none;
    position: relative;
    background-color: rgb(26, 207, 132);
    width: 50%;
}
4
  • SlideUp only hides it does not show. Best to consult the jquery documentation api.jquery.com/slideUp
    – Funk Doc
    Commented May 7, 2019 at 18:35
  • You might want to familiarize yourself with css transitions to get your desired effect
    – Funk Doc
    Commented May 7, 2019 at 18:37
  • As Funk Doc mentioned the slideUp is used to hide the element while sliding in up direction. You cannot reveal an element using slideUp. Look into Jquery animate or CSS transitions
    – Nawed Khan
    Commented May 7, 2019 at 18:56
  • Oh... that'd explain it! It's a shame, I'm trying to use jQuery as much as possible just to learn it, remember the syntax etc. Oh, well, I'll go the CSS route. Thank you both.
    – jesusWalks
    Commented May 7, 2019 at 19:16

0

Browse other questions tagged or ask your own question.