Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging the border on table without causing a table to resize
    primarykey
    data
    text
    <p>I asked a <a href="https://stackoverflow.com/questions/13496559/how-can-a-html-table-highlight-columns-by-changing-the-border-on-hover">question</a> earlier about a way of highlighting tables using <code>JavaScript</code> and `CSS. I'm having difficulty ensuring that the borders of the table look ok.</p> <p>For example, in my table border I have set the margin to be <code>0</code>. When hovering on a column, the increased border size causes the overall table to "jump" slightly. To prevent this I tried to resize the table cells but this does not make a difference.</p> <p><img src="https://i.stack.imgur.com/ifkqM.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/1yUfn.png" alt="enter image description here"></p> <p>I'm illustrating the problem with a JSFiddle here: <a href="http://jsfiddle.net/grNr8/6/" rel="nofollow noreferrer">http://jsfiddle.net/grNr8/6/</a>. It's a little hard to see in these images but hopefully the fiddle illustrates the issue.</p> <p>My <code>CSS</code> is the following:</p> <pre><code>table, td { background-color: white; border: 0px solid white; border-collapse: collapse; } </code></pre> <p>When highlighting the column, a border of pixel thickness <code>2</code> is chosen. I tried experimenting with changing the cell size using <code>$('td').css({height: '29px'});</code> (and varying from <code>26 - 29</code>) but it does not change the effect. The <code>Javascript</code> I am using to highlight is based mainly on an answer to my previous question:</p> <pre><code>$('td').hover(function() { var t = parseInt($(this).index()) + 1; $('td:nth-child(' + t + ')').first().addClass('highlightedTop'); $('td:nth-child(' + t + ')').addClass('highlighted') $('td:nth-child(' + t + ')').last().removeClass('highlighted').addClass('x'); $('td').css({ height: '39px' }); if (t &gt; 1) { var t1 = t - 1; $('td:nth-child(' + t1 + ')').addClass('highlightedPrev'); $('td:nth-child(' + t1 + ')').last().removeClass('highlightedPrev'); } }, function() { var t = parseInt($(this).index()) + 1; $('td:nth-child(' + t + ')').removeClass('highlighted '); $('td:nth-child(' + t + ')').first().removeClass('highlightedTop'); $('td:nth-child(' + t + ')').last().removeClass('highlightedBottom'); $('td:nth-child(' + t + ')').last().removeClass('x'); if (t &gt; 1) { var t1 = t - 1; $('td:nth-child(' + t1 + ')').removeClass('highlightedPrev'); } });​ </code></pre> <p>Is it possible to resize the cells for smoother viewing, or should I be using a different approach? I have experimented with using a white border thickness of <code>1px</code> but I end up with strange joins at the corners and un-symmetric borders at the extremities.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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