javascript - How do you transition a height without the element going outside the parents border? -


i trying make transition starts @ top , after page loads, content expands down page.

i've gotten of working, except when content expands down page, keeps expanding way outside it's parents borders. have elements set expand 100%, thought expanding elements expand 100% of parents size, keeps going down page.

perhaps misunderstanding how parent/child height percentages work. can point out doing wrong? thanks.

here link code on jsfiddle

here html code:

<body>     <div id="outer">         <div class="middle">             <div class="inner">                  <h3>a-b</h3>                  <ul>                     <li>a</li>                     <li>b</li>                 </ul>             </div>             <div class="inner">                  <h3>c-g</h3>                  <ul>                     <li>c</li>                     <li>d</li>                     <li>e</li>                     <li>f</li>                     <li>g</li>                 </ul>             </div>             <div class="inner">                  <h3>h</h3>                  <ul>                     <li>h</li>                 </ul>             </div>         </div>     </div> </body> 

here javascript code:

window.onload = function () {     document.getelementbyid("outer").setattribute("class", "loaded"); } 

here css:

html {     height: 100%; } body {     height: 100%; } #outer {     height: 100%; } .middle {     border: solid 2px black;     height: 100%; } .inner {     height: 0%;     transition: height 5s 2s;     -moz-transition: height 5s 2s;     -webkit-transition: height 5s 2s;     -o-transition: height 5s 2s; } #outer.loaded .inner {     height: 100%; } 

percentages based on parent. setting 3 divs class .inner height 100%. means total height 300%. set .inner 33% more reasonable.

edit

just out of interest, found article on here on might trying do, transition height 0 transition height auto, involves setting max-height number big (well @ least bigger auto height), transitions auto anyway. link here


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -