Note that there are some explanatory texts on larger screens.

plurals
  1. POScroller with dynamically sized headers/footers
    primarykey
    data
    text
    <p>What I'm looking for is to have a container <code>div</code> with any number of headers and footers which would then have another scrolling <code>div</code> in between the various headers/footers. The catch is here that the headers and footers can't scroll and the container/headers/footers can take any height depending on their content.</p> <p>I've only been able to get this working with a statically sized header/footer. In the code I've added the problem I've come across: the text in the header/footer may wrap, which will bring it to two lines. So the header should grow to allow this extra line and the content should shrink to give space to the header. Is there any way to do this without using javascript? I will know the number of headers/footers ahead of time if that helps.</p> <p>This is going to be a component in a page possibly with one or more per page, for example in a 2x2 setup where each takes up a 4th of the browser window. The functionality is mainly needed as the width of the browser might change causing the header content to break a new line. This could be done pretty easily with javascript but I've always heard that <code>resize</code> event handlers are evil.</p> <p>For example if my wrapper is <code>600px</code> high, I may have 2 headers and 1 footer. Lets say the first header's content causes it to break to a new line, but the second header's doesn't. So the first headers height is <code>20px</code> where the second's is <code>10px</code>. And lets say the footer's content also causes a line break and thus has <code>20px</code> height. This gives us <code>50px</code> worth of headers and footers so now the height of the scroller should be <code>550px</code>.</p> <p>Ascii Art:</p> <pre><code> ____________________________________________ | HEADER 1 | |________breaks to new line__________________| |____________________________HEADER2_________| | | || | | || | This is my scroller | || | | || | | || | | || |_________________________________________|_|| | Some | |_____Footer_________________________________| </code></pre> <p>HTML:</p> <pre><code>&lt;div class="wrapper"&gt; &lt;div class="header"&gt; Some&lt;br/&gt; Header &lt;/div&gt; &lt;div class="scroller"&gt; Content&lt;br /&gt; Content&lt;br /&gt; Content&lt;br /&gt; Content&lt;br /&gt; ... &lt;/div&gt; &lt;div class="footer"&gt; Some&lt;br/&gt; Footer &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS:</p> <pre><code>body{ height:100%; } .wrapper{ height:400px; border-left:1px solid red; } .header, .footer{ background-color: #EEE; height:27px; } .scroller{ height:calc(100% - 54px); background-color: #CCC; overflow:auto; } </code></pre> <p>the red border is to show how far the wrapper goes down, so the footer doesn't show up below. I did this instead of <code>overflow: hidden</code> simply for debugging.</p> <p><a href="http://jsfiddle.net/yKTdz/4/" rel="nofollow">http://jsfiddle.net/yKTdz/4/</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.
 

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