0

i'm working on a program list where if you click on a button a box opens and the info text appears. I just used CSS transitions, but they don't seem to work, I don't know where the problem lies, so maybe you guys could help? Thanks in advance!

Here is the JSFidlle: https://jsfiddle.net/g3v0q11L/1/

HTML

<div class="program">
  <div class="pblock">
    <div class="pb-top">
      <div class="date">Di. 23 Aug.</div>
    </div>
    <div class="pb-bottom">
      <div class="info">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta.
        Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean
        quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris
        ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
      </div>
    </div>
    <div class="opener"></div>
  </div>
</div>

JQuery

$(document).ready(function() {
  $('.opener').click(function() {
    $('.opener').toggleClass('turn');
    $('.info').toggleClass('there');
    $('.pb-bottom').toggleClass('opened');
  });
});

CSS

.program {
  position: relative;
  width: 100vw;
  height: 100vh;
  background-color: red;
}

.pblock {
  top: 100px;
  position: relative;
  left: calc(50% - 45vw);
  width: 90vw;
  height: auto;
  min-height: 150px;
  margin: 0;
  padding: 0;
}

.pb-top {
  position: relative;
  height: 100px;
}

.date {
  color: white;
  font-size: 1.3em;
  font-family: 'FBold';
  display: inline;
  position: absolute;
  top: 70px;
}

.pb-bottom {
  position: relative;
  -webkit-transition: all 1s ease-out;
  transition: all 1s ease-out;
  height: 0px;
  border-top: 1px solid white;
  border-bottom: 1px solid white;
}

.opened {
  height: auto !important;
}

.info {
  -webkit-transition: all 1s ease-out;
  transition: all 1s ease-out;
  display: none;
  opacity: 0;
}

.there {
  display: block;
  opacity: 1;
}

.opener {
  position: relative;
  top: 10px;
  width: 50px;
  left: calc(50% - 25px);
  height: 40px;
  background: rgba(255, 255, 255, 0.5);
  border-bottom: 2px solid purple;
  transition: transform 0.2s ease-in-out;
  transform-origin: center;
  animation: flicker 3s ease-in-out infinite;
}

.turn {
  transform: rotate(180deg);
}

@keyframes flicker {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
  100% {
    opacity: 1;
  }
}
ERRO
  • 1
  • 1
  • 1
    You can't transition between `display: none` and `display: block`. How do you want it to transition? Sliding up/down? Fading in/out? There are a lot of possibilities, so it is unclear what kind of transition you are looking for. – Terry May 09 '18 at 21:40
  • Transition can only work on property values that can have intermediate state. height in your example can have intermediate state – Rikin May 09 '18 at 21:46
  • I figured it out, it was indeed similar to the other question. I change the display attribute to visibility and with the box itself a height transition from 0 to auto is also impossible, so I gave it a specified height to transition to. Thank you very much – ERRO May 09 '18 at 21:48

0 Answers0