Note that there are some explanatory texts on larger screens.

plurals
  1. POFloating Inner Div to affect height of parent
    text
    copied!<p>I've created a JSFiddle to describe what I mean:</p> <p><a href="http://jsfiddle.net/3yGLT/" rel="nofollow">http://jsfiddle.net/3yGLT/</a></p> <p>I want my <code>.top</code> section to be affected by the height of the <code>.floated-div</code>, as you can see. At present, my <code>.floated-div</code> content drops over the <code>.bottom</code> section, which is not what I want. The height of the <code>.floated-div</code> needs to dictate the height of the <code>.top</code> section, effectively pushing <code>.bottom</code> down to make room for it.</p> <p>I thought Clear divs were the solution I wanted, but it's not giving me the behaviour I'm after. I think this would only apply if the main content of <code>.top</code> was in a similar div to <code>floated-div</code> and not embedded in this way.</p> <p>I can add things like clears, but I can't adjust the structure of this code as it's something that's generated through the CMS.</p> <p><strong>HTML</strong></p> <pre><code>&lt;section class="top"&gt; &lt;h1&gt;test&lt;/h1&gt; &lt;p&gt;some content&lt;/p&gt; &lt;div class="floated-div"&gt; &lt;h2&gt;aside content&lt;/h2&gt; &lt;p&gt;some aside content&lt;/p&gt; &lt;p&gt;some aside content&lt;/p&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/section&gt; &lt;section class="bottom"&gt; &lt;/section&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>.top{ width: 60%; height:auto; background:#f1f1f1; } .floated-div{ width:40%; position:absolute; right:0; top:0; } .clear{ clear:both; } .bottom{ width: 100%; height:100px; background:#d1d1d1; } </code></pre>
 

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