Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want a table where only the columns scroll horizontally, you can <code>position: absolute</code> the first column (and specify its width explicitly), and then wrap the entire table in an <code>overflow-x: scroll</code> block. Don't bother trying this in IE7, however...</p> <p>Relevant HTML &amp; CSS:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>table { border-collapse: separate; border-spacing: 0; border-top: 1px solid grey; } td, th { margin: 0; border: 1px solid grey; white-space: nowrap; border-top-width: 0px; } div { width: 500px; overflow-x: scroll; margin-left: 5em; overflow-y: visible; padding: 0; } .headcol { position: absolute; width: 5em; left: 0; top: auto; border-top-width: 1px; /*only relevant for first row*/ margin-top: -1px; /*compensate for top border*/ } .headcol:before { content: 'Row '; } .long { background: yellow; letter-spacing: 1em; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt; &lt;table&gt; &lt;tr&gt;&lt;th class="headcol"&gt;1&lt;/th&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;th class="headcol"&gt;2&lt;/th&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;th class="headcol"&gt;3&lt;/th&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;th class="headcol"&gt;4&lt;/th&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;th class="headcol"&gt;5&lt;/th&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;th class="headcol"&gt;6&lt;/th&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;td class="long"&gt;QWERTYUIOPASDFGHJKLZXCVBNM&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><a href="http://jsfiddle.net/emn13/YMvk9/" rel="noreferrer">Fiddle</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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