Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Pure CSS Answer (CSS3)</h2> <p>There are some careful considerations to take into account (see below), but <a href="http://jsfiddle.net/yjkLT/140/" rel="nofollow">there does appear to be a way to do this in pure css</a> (note that fiddle uses the fake <code>div</code> table per this post, but it could be done with real html tables) using a <code>linear-gradient</code> with color stops (technique found <a href="http://lea.verou.me/2010/12/checkered-stripes-other-background-patterns-with-css3-gradients/" rel="nofollow">here</a>) on the <code>table</code> background. The key to make it flexible with <code>font-size</code> changes (or zooming) is to set the height portion of the <code>background-size</code> to twice the <code>line-height</code> set for the rows.</p> <p><strong>Considerations:</strong></p> <ol> <li><code>line-height</code> and <code>font-size</code> for <code>row</code> should be explicitly set with <code>em</code> units (except see note #5 below).</li> <li>If <code>padding</code> is set on the <code>table</code> (not recommended) then some type of adjustment to either <code>background-position</code> or <code>background-clip</code> will likely need to be done to accommodate the padding.</li> <li>If top or bottom <code>padding</code> or <code>margin</code> is set on the <code>row</code> then it should be in <code>em</code> units and added to the <code>line-height</code> value before calculating the doubled <code>linear-gradient</code> height.</li> <li>This technique will change color of background <strong><em>within a row</em></strong> if that row has multiple lines in it (<a href="http://jsfiddle.net/yjkLT/140/" rel="nofollow">see <strong>the last table</strong> in my example fiddle</a>).</li> <li>If some other fixed height element were in the rows (images set to 20px high), then the <code>row</code> height and <code>linear-gradient</code> height could be set based off pixel values.</li> </ol> <p>I have not taken the time to play around with #2 and #3 above to figure out for sure the exact adjustments needed, but theoretically it should be possible to accommodate those things if necessary.</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. 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.
 

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