Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get an element to always occupy a specific percentage of its parent element, even when the browser is resized?
    primarykey
    data
    text
    <p><strong>Note: I know that <code>elem {height: 90%}</code> exists.</strong></p> <p>What I need:</p> <ul> <li>an element to occupy x% width and y% height of its parent element, regardless of size</li> <li>the parent has margins and padding</li> </ul> <p>My problem:</p> <ul> <li>it looks great at first, but when I make the browser window smaller, content starts spilling out of the bottom of the parent. <strong>This is super depressing.</strong> It looks to me like the size of the <code>#load</code> div is 90% of its parent <em>(as requested; see stylesheet below)</em>; unfortunately this 90% doesn't take margins or padding into account. <strong>What is going on here?</strong> If the answer is just that percentages don't work "like that" when there are margins/padding, <strong>how do I specify that an element occupies x percent of its parent after deducting margins/padding?</strong> Also, note that jQueryui uses css that I would like to avoid touching, if possible.</li> </ul> <p>My markup:</p> <pre><code>&lt;div id="tabscontainer"&gt; &lt;div id="tabs"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#create"&gt;Create&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#load"&gt;Load&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="create"&gt; something or other &lt;/div&gt; &lt;div id="load"&gt; ... there is a lot of content here ... &lt;/div&gt; &lt;/div&gt; &lt;script&gt; $(document).ready(function() {$("#tabs").tabs();}); &lt;/script&gt; </code></pre> <p>My styling:</p> <pre><code>html, body { height: 100%; } #tabscontainer { height: 95%; } #tabs { height: 100%; } #tabs &gt; div { height: 90%; overflow: auto; } </code></pre> <p>Also, the default jQuery styling of tabs is in effect (with no changes from me).</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.
 

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