Note that there are some explanatory texts on larger screens.

plurals
  1. PODiv not exactly equalling height of parent div with inherit value
    primarykey
    data
    text
    <p>I have 3 divs inside a parent div, intended to be arranged like so:</p> <pre><code> ______________________________________ | | | HEADER | |______________________________________| ____ _______________________________ | | | | | | | | | | | | | | | | | N | | | | A | | CONTENT | | V | | | | - | | | | B | | | | A | | | | R | | | | | | | | | | | |____| |_______________________________| </code></pre> <p>The <code>#header</code> is fixed height, so I'm having no issues with it.</p> <p>However, the <code>#content</code> div's, well, content, is dynamic, depending on the page that is loaded. I want <code>#nav-bar</code> to match the height of <code>#content</code> at all times, but I haven't been able to manage it.</p> <p>I want the min-height of <code>#content</code> and <code>#nav-bar</code> to be 100% of the screen height (so they take up the full height of the screen at minimum at all times), but then as <code>#content</code> grows beyond that, I want <code>#nav-bar</code> to grow accordingly.</p> <p>I've gotten <code>#nav-bar</code>'s height to grow, but not at exactly the same value as <code>#content</code>, so their heights are still mismatched.</p> <p>Here is the relevant code I have in place, and <a href="http://jaddl.clanteam.com/index2.php" rel="nofollow">the actual page in question is here</a>.</p> <p><strong>HTML:</strong></p> <pre class="lang-html prettyprint-override"><code>&lt;div id='container'&gt; &lt;div id='center-panel'&gt; &lt;div id='top-banner'&gt;&lt;/div&gt; &lt;div id='nav-bar'&gt; &lt;?php echo get_nav_list(); ?&gt; &lt;/div&gt; &lt;div id='header'&gt;&lt;span id='fact-tag'&gt;current points leader&lt;/span&gt;&lt;span id='fact-value'&gt;4&lt;/span&gt;&lt;/div&gt; &lt;div id='content'&gt;Lorem ipsum... &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>CSS:</strong></p> <pre class="lang-css prettyprint-override"><code>html, body { background-color: #ccc; min-height: 100%; margin: auto; font-family: 'Noto Sans', 'Tahoma', sans-serif; font-size: 12pt; color: #666; } #container { height: 100%; overflow: scroll; } #center-panel { margin-left: auto; margin-right: auto; width: 800px; background-color: #fff; min-height: 100%; } #header { /*top bar*/ height: 33px; max-height: 33px; text-align: right; color: #aaa; padding: 0px 15px 0px 160px; font-size: 18pt; border: 2px dashed blue; } #header span#fact-tag { font-weight: 700; } #header span#fact-value { display: inline-block; min-width: 40px; background-color: #ccc; margin-left: 10px; color: #444; padding: 0px 3px 0px 3px; } #nav-bar { /*left bar*/ float: left; width: 110px; text-align: center; height: inherit; font-family: 'Oxygen', 'Tahoma', sans-serif; padding: 33px 0px 0px 0px; border: 2px dashed red; } #nav-bar ul { /*main menu*/ list-style-type: none; text-align: left; font-size: 10pt; padding: 0px; margin: 0px; } #nav-bar &gt; ul &gt; li { /*main menu item*/ min-height: 35px; background-color: #444; color: #ccc; border-left: 6px solid #444; border-bottom: 3px solid #666; cursor: pointer; } #nav-bar ul &gt; li &gt; ul { /*sub-menu*/ display: none; } #nav-bar ul &gt; li &gt; ul &gt; li { /*sub-menu item*/ min-height: 25px; background-color: #555; border-bottom: 3px solid #444; font-size: 10pt; cursor: pointer; } #nav-bar ul &gt; li &gt; ul &gt; li &gt; ul &gt; li { /*third-level menu item*/ border: none; min-height: 10px; font-size: 8pt; cursor: pointer; } #content { /*central content area*/ padding: 60px 45px 30px 160px; border: 2px dashed green; } </code></pre> <p><strong>Javascript:</strong></p> <pre class="lang-js prettyprint-override"><code>$('#nav-bar ul li').on('click', function() { $(this).css('border-left-color', '#ad9557').siblings().css('border-left-color', '#666'); $(this).children().slideDown('fast'); $(this).siblings().children('ul').slideUp('fast'); }); $('#nav-bar').css('height', $('#container').height()); </code></pre>
    singulars
    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.
 

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