Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you wrap the .block div with a container:</p> <pre><code>&lt;div class="container"&gt; &lt;div class="block"&gt;&lt;/div&gt; &lt;/div&gt; &lt;button&gt;Click&lt;/button&gt; </code></pre> <p>you could expand and then, translate the container itself <strong>after</strong> the click event</p> <pre><code>document.querySelector("button").addEventListener("click", function () { document.querySelector(".container").classList.add("hide"); }); </code></pre> <p>with this style</p> <pre><code>.block { position:absolute; bottom:10px; right:10px; left:10px; height:100px; background:gray; } .container { -webkit-transition: -webkit-transform ease-in-out 1s; -webkit-transform-origin: top; -webkit-transition-delay: 0.1s; /* Needed to calculate the vertical area to shift with translateY */ } .container.hide { position:absolute; top:0; left:0; bottom:0; right:0; /* background:#f00; /* Uncomment to see the affected area */ -webkit-transform: translateY(-110%); } </code></pre> <p>In this way, it is possible to apply a correct translationY percentage ( a little more than 100%, just to have it out of the way ) and mantaining the button clickable.</p> <p>You could see a working example here : <a href="http://jsfiddle.net/MG7bK/" rel="noreferrer">http://jsfiddle.net/MG7bK/</a></p> <p>P.S: I noticed that the transition delay is needed only for the transitionY property, otherwise the animation would fail, probably because it tries to start before having an actual value for the height. It could be omitted if you use the horizontal disappearing, with translateX. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload