Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS: Child div overlapping parent
    primarykey
    data
    text
    <p>I have something vaguely like the following:</p> <pre><code>&lt;div id="body"&gt; surrounding text &lt;div id="pane" style="overflow: auto; height: 500px; width: 500px;"&gt; lots and lots of text here &lt;span id="some_bit"&gt;tooltip appears below-right of here&lt;/span&gt; &lt;/div&gt; more surrounding text (should be overlapped by tooltip) &lt;/div&gt; </code></pre> <p>and:</p> <pre><code>&lt;div id="tooltip" style="width: 100px; height: 100px;"&gt;Whee&lt;/div&gt; </code></pre> <p>What I want to do is insert the tooltip such that it is positioned <em>above</em> the pane it's in. If it's attached to an element that's next to the pane boundary (like above), then it should be visible above the pane, and above the text surrounding the pane. </p> <p>It should NOT a) extend the pane, such that you have to scroll down to see the tooltip (like in <a href="http://saizai.com/css_overlap.png" rel="nofollow noreferrer">http://saizai.com/css_overlap.png</a>), or b) be cut off, so you can't see all of the tooltip.</p> <p>I'm inserting this with JS, so I can add a wrapper <code>position:relative</code> div or the like if needed, calculate offsets and make it <code>position:absolute</code>, etc. I would prefer to not assume anything about the pane's <code>position</code> property - the tooltip should be insertable with minimal assumptions of possible page layout. (This is just one example case.)</p> <p>It's for a prototype tooltip library I'm writing that will be open source.</p> <p>ETA: <a href="http://jsfiddle.net/vCb2y/5/" rel="nofollow noreferrer">http://jsfiddle.net/vCb2y/5/</a> behaves <em>visually</em> like I want (if you keep re-hovering the trigger text), but would require me to update the position of the tooltip on all DOM changes and scrolling behavior. I would rather the tooltip be positioned with pure CSS/HTML so that it has the same visual behavior (i.e. it overlaps <em>all</em> other elements) but stays in its position relative to the target under DOM changes, scrolling, etc.</p> <p>ETA 2: <a href="http://tjkdesign.com/articles/z-index/teach_yourself_how_elements_stack.asp" rel="nofollow noreferrer">http://tjkdesign.com/articles/z-index/teach_yourself_how_elements_stack.asp</a> (keep defaults except set cyan div 'a' to position:relative; imagine 'A' is the pane and 'a' the tooltip) seems to more closely behave as I want, but I've not been able to get it to work elsewhere. Note that if you make 'A' <code>overflow: auto</code>, it breaks the overlapping behavior of 'a'.</p>
    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