Note that there are some explanatory texts on larger screens.

plurals
  1. POPixel & Percent in a HTML-Table
    primarykey
    data
    text
    <p>I'm working on a stats table for soccer(Football) games.</p> <p>The table consists of the following columns (from left to right):</p> <ul> <li>icon</li> <li>text (what happend)</li> <li>minute</li> <li>text (what happend)</li> <li>icon</li> </ul> <p>The icon &amp; minute columns should have a static with (50px &amp; 80px). The text columns should be variable in width.</p> <p>Now to the tricky part... if the table has a text column with content and one without in the same row the minute column isn't centered anymore. See:</p> <p><img src="https://i.stack.imgur.com/lLeM0.png" alt="enter image description here"></p> <p>That's how it should look like:</p> <p><img src="https://i.stack.imgur.com/SHWSE.png" alt="enter image description here"></p> <p>Here is the code:</p> <pre><code>&lt;table class="table-comparison"&gt; &lt;thead&gt; &lt;th colspan="5"&gt; Wechsel &lt;/th&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="column-action"&gt;&lt;i class="icon-rotate-left"&gt;&lt;/i&gt;&lt;/td&gt; &lt;td class="column-text text-right"&gt; &lt;i class="icon-caret-right color-green"&gt;&lt;/i&gt; Sradan Lakic für &lt;i class="icon-caret-right color-red-light"&gt;&lt;/i&gt; Stefan Aigner &lt;/td&gt; &lt;td class="column-center" data-toggle="move:insertBefore" data-target="$el.parent().find('td:first-child')"&gt;46'&lt;/td&gt; &lt;td class="column-text"&gt; &lt;div&gt; &lt;i class="icon-caret-right color-green"&gt;&lt;/i&gt; Mario Götze für &lt;i class="icon-caret-right color-red-light"&gt;&lt;/i&gt; Toni Kroos &lt;/div&gt; &lt;div&gt; &lt;i class="icon-caret-right color-green"&gt;&lt;/i&gt; Emre Can für &lt;i class="icon-caret-right color-red-light"&gt;&lt;/i&gt; Thiago Alcantara &lt;/div&gt; &lt;/td&gt; &lt;td class="column-action"&gt;&lt;i class="icon-rotate-left"&gt;&lt;/i&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="column-action"&gt;&lt;i class="icon-rotate-left"&gt;&lt;/i&gt;&lt;/td&gt; &lt;td class="column-text text-right"&gt; &lt;i class="icon-caret-right color-green"&gt;&lt;/i&gt; Sebastion Jung für &lt;i class="icon-caret-right color-red-light"&gt;&lt;/i&gt; Marco Russ &lt;/td&gt; &lt;td class="column-center" data-toggle="move:insertBefore" data-target="$el.parent().find('td:first-child')"&gt;88'&lt;/td&gt; &lt;td class="column-text"&gt;&lt;/td&gt; &lt;td class="column-action"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>and the css:</p> <pre><code>// ------------------------------ .table-comparison { color: @black; width: 100%; th, td { padding: 10px 0; } th { .interstate; .uppercase; color: @black; font-size: 14px; padding-top: 0; padding-bottom: 15px; @media @tablet { padding-bottom: 35px; text-align: center; } } .column-action { padding-left: 20px; padding-right: 20px; text-align: center; width: 20px; @media @phone { display: none; } } .column-text { padding-left: 20px; padding-right: 20px; @media @phone { display: block; height: auto; text-align: left; width: 100%; } } .column-center { .interstate; text-align: center; width: 80px; @media @phone { display: block; height: auto; padding-left: 20px; text-align: left; width: 100%; } @media @tablet { border-left: 1px solid @grey-medium; border-right: 1px solid @grey-medium; } } // stripe that shit down // stripe down the tables &gt; tbody &gt; tr:nth-child(even) &gt; td, &gt; tbody &gt; tr:nth-child(even) &gt; th { background-color: #f7f7f7; } &gt; tbody &gt; tr:nth-child(odd) &gt; td, &gt; tbody &gt; tr:nth-child(odd) &gt; th { background-color: transparent; } } </code></pre>
    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