0

Just to let you know. I figured how to cope with the holy grail of CSS3 - animation to the maximum height. See my example:

<style>

* {
  margin: 0;
  -webkit-transform: translate3d(0,0,0);
}

input[type="radio"] {
  display: none;
}

label {
  transform: translateY(100%);
  display: block;
  transition: all 0.5s cubic-bezier(.22,.61,.36,1);
  background-color: white;
  will-change: transform;
}

label[for^=radio1] {
  transform: translateY(0);
}

.outer {
  overflow: hidden;
}

.mid {
  transform: translateY(-100%);
  transition: all 0.5s cubic-bezier(.22,.61,.36,1);
  will-change: transform;
}

.inner.absolute {
  height: 100%;
  width: 100%;
  position: absolute;
  transition: all 0.5s cubic-bezier(.22,.61,.36,1);
  will-change: transform;
}

ul, .inner { 
  visibility: hidden;
}

ul.absolute {
  position: absolute;
  visibility: visible;
  bottom: 0;
}

input[type="radio"]:checked + label .outer .mid label .outer .mid label {
  transform: translateY(100%);
}

input[type="radio"]:checked + label .outer .mid label .outer .mid,
input[type="radio"]:checked + label .outer .mid .inner.absolute, .inner.absolute:last-child {
  transform: translateY(-100%);
}

input[type="radio"]:checked + label .outer .mid,  input[type="radio"]:checked + label .outer .mid label, 
input[type="radio"]:checked + label .outer .mid label .outer .mid .inner.absolute:not(:last-child) {
  transform: translateY(0);
}

</style>


<input id="radio1" type="radio" name="toggle"></input>
<label for="radio1">
  <p>Test 1</p>
  <div class="outer">
    <div class="mid">
     <div class="inner">
      <ul>
        <li>Test A</li>
        <li>Test B</li>
        <li>Test C</li>
        <li>Test B</li>
        <li>Test C</li>
        <li>Test B</li>
        <li>Test C</li>
        <li>Test B</li>
        <li>Test C</li>
      </ul></div><div class="inner absolute"><ul class="absolute">
        <li>Test A</li>
        <li>Test B</li>
        <li>Test C</li>
        <li>Test B</li>
        <li>Test C</li>
        <li>Test B</li>
        <li>Test C</li>
        <li>Test B</li>
        <li>Test C</li>
      </ul></div>
      <input id="radio2" type="radio" name="toggle"></input>
      <label for="radio2">
        <p id="p2">Test 2</p>
        <div class="outer">
          <div class="mid">
           <div class="inner">
            <ul>
              <li>Test A</li>
              <li>Test B</li>
              <li>Test C</li>
            </ul></div><div class="inner absolute"><ul class="absolute">
              <li>Test A</li>
              <li>Test B</li>
              <li>Test C</li>
            </ul></div>
            <input id="radio3" type="radio" name="toggle"></input>
            <label for="radio3">
              <p id="p2">Test 3</p>
              <div class="outer">
                <div class="mid">
                 <div class="inner">
                  <ul>
                    <li>Test A</li>
                  </ul></div><div class="inner absolute"><ul class="absolute">
                    <li>Test A</li>
                  </ul></div>
                  <input id="radio4" type="radio" name="toggle"> </input>
                  <label for="radio4">
                    <p id="p2">Test 4</p>
                    <div class="outer">
                      <div class="mid">
                       <div class="inner">
                        <ul>
                          <li>Test A</li>
                          <li>Test B</li>
                          <li>Test C</li>
                          <li>Test B</li>
                          <li>Test C</li>
                        </ul></div><div class="inner absolute"><ul class="absolute">
                          <li>Test A</li>
                          <li>Test B</li>
                          <li>Test C</li>
                          <li>Test B</li>
                          <li>Test C</li>
                        </ul></div>
                        <input id="radio5" type="radio" name="toggle"></input>
                        <label for="radio5">
                          <p id="p2">Test 5</p>
                          <div class="outer">
                            <div class="mid">
                             <div class="inner">
                              <ul>
                                <li>Test A</li>
                                <li>Test B</li>
                                <li>Test C</li>
                                <li>Test B</li>
                                <li>Test C</li>
                                <li>Test C</li>
                              </ul></div><div class="inner absolute"><ul class="absolute">
                                <li>Test A</li>
                                <li>Test B</li>
                                <li>Test C</li>
                                <li>Test B</li>
                                <li>Test C</li>
                                <li>Test C</li>
                              </ul></div>
                            </div>
                          </div>
                        </label>
                      </div>
                    </div>
                  </label>
                </div>
              </div>
            </label>
          </div>
        </div>
      </label>
    </div>
  </div>
</label>
</div>
</div>
</label>

http://codepen.io/kyvaith/pen/WwzVXK

I already used much more complex version of this code on production, so it's not just PoC. Regards!

kyvaith
  • 11
  • So... what is the question? – Daniel Higueras Apr 15 '16 at 11:33
  • Self-answering is fine but you must use the Question and Answer format expected on Stack Overflow. Post a question that highlights a problem that needs to be solved, then provide that answer _as an answer_, not within the question itself. Otherwise this thread will be closed. – Turnip Apr 15 '16 at 11:44
  • ... _but_, as this question has already been asked _many_ times, it would be better to add your solution as an answer to an exiting question. Like this for example: http://stackoverflow.com/questions/3508605/how-can-i-transition-height-0-to-height-auto-using-css – Turnip Apr 15 '16 at 11:46
  • Sorry, I was unable to post answer on other topic, because I need 10 points on Stack to do this, and this was my first post. Will try better in future :) – kyvaith Apr 16 '16 at 13:08

0 Answers0