Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For those of a visual dependence <a href="http://jsfiddle.net/TV7mU/3/" rel="nofollow">:) fiddlywiddly</a></p> <p>You may have to tweak this to your specifications but this will do the trick:</p> <h2>Javascript:</h2> <p><em>Change '.append()' to '.prepend()'</em></p> <pre><code>$(document).ready(function () { $(".iframe").click(function () { var file = $(this).data("url"); var size = $(this).data("size"); var $one = $('#one'); $one.prepend("&lt;h5 class='button open'&gt;Hide Frame&lt;/h5&gt;&lt;div class='frame-contain'&gt;&lt;iframe class='articleframe' height=0 src='" + file + "'&gt;&lt;/iframe&gt;&lt;/div&gt;"); var $wrap = $one.find('.frame-contain:first'); $wrap.animate({ height: size }, { duration: 1000, step: function (now) { $(this).height(now); $(this).nextAll('.frame-contain').offsetParent().top += now; $(this).find('iframe').height(now); }, complete: function () { $(".open").click(function () { $(this).next('div').slideUp(1000); $(this).fadeOut('slow'); }); } }); }); }); </code></pre> <p>I would also suggest re-arranging your elements but that's up to you. You can put your <code>&lt;h5&gt;</code> buttons into a <code>&lt;header&gt;</code> and the <code>&lt;iframe&gt;</code> creations into a <code>&lt;section&gt;</code>. Food for thought. That way your buttons don't go flying all over the place. My example utilizes this idea.</p> <h2>HTML:</h2> <pre><code>&lt;article&gt; &lt;header&gt; &lt;h2&gt;Querybox&lt;/h2&gt; &lt;h5 class="button iframe" data-url="http://www.bbc.co.uk" data-size="900"&gt;Load another file&lt;/h5&gt; &lt;/header&gt; &lt;section id="one"&gt;&lt;/section&gt; &lt;/article&gt; </code></pre> <h2>CSS:</h2> <pre><code>iframe, header, section, div { clear: left; position: relative; display: block; } section, div { width: 100%; max-height: 100%; } .open { clear: left; display: block; } .articleframe { float: left; } </code></pre> <p>Since I am uncertain of your end-game here I made my best interpretation. Keep in mind this code is horribly inefficient the way it is set-up (so many selectors utilizing jQuery is very code intensive). </p> <p>I would suggest you put more <code>id</code> tags on things and reference those using <code>$(document.getElementById('id'))</code> or <code>$(document.querySelector('#id'))</code>. Also, using jQuery <code>.width()</code> and <code>.height()</code> takes a huge hit as well. You should use a javascript native selector and then apply <code>.innerWidth = XX</code> or <code>.innerHeight = XX</code>.</p> <p>Normally performance at this small of scale isn't hugely important but given what you're displaying and the impact it has on the browser, it may help you.</p> <p>For examples on the performance gain: <a href="http://jsperf.com/innerheight-vs-height" rel="nofollow">JSPerf - innerHeight vs. .height()</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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