Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS puzzle : absolute position of table title
    primarykey
    data
    text
    <h2>HTML structure</h2> <p>I've got the following html structure: <strong>This is a fixed structure that I can't edit</strong></p> <pre><code>&lt;div class="separator"&gt;&lt;/div&gt; &lt;table class="myClass"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;title1&lt;/th&gt; &lt;th&gt;title2&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; ... &lt;/table&gt; &lt;div class="separator"&gt;&lt;/div&gt; </code></pre> <hr> <h2>CSS</h2> <p>The first and last div are separators whose css is:</p> <pre><code>.separator { height: 20px; background-color: gray; } </code></pre> <p><strong>Note that separators are complex widgets and not only design (I've intentionnaly simplified the example)</strong></p> <hr> <h2>The problem</h2> <p>I want to position the table header <strong>before</strong> the first separator but the table body must remain between the two separators.</p> <hr> <h2>What I have tried</h2> <ol> <li><p>Here is the initial jsfiddle for testing: <a href="http://jsfiddle.net/prhgW/1/" rel="nofollow">http://jsfiddle.net/prhgW/1/</a></p></li> <li><p>I've tried to position absolute the thead tag and use negative top values but when doing so, the width of the thead is smaller than 100% of the table and so column titles are misplaced regarding the column value. the fiddle: <a href="http://jsfiddle.net/prhgW/2/" rel="nofollow">http://jsfiddle.net/prhgW/2/</a></p></li> <li><p>I've also tried to put the width at 100% but the tr tag do not follow that rules : <a href="http://jsfiddle.net/prhgW/3/" rel="nofollow">http://jsfiddle.net/prhgW/3/</a></p></li> </ol> <hr> <h2>Additional rules</h2> <ul> <li>I would like to avoid fixed width/height of the table or any element (so, absolute positioning everything is not acceptable solution)</li> <li>I would like cross browser compatibility</li> <li>avoid javascript fix (pure css would be better)</li> </ul>
    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