views:

316

answers:

3

Hi, I created a table without borders styling and I want it to underline a row on hover. However, I am getting pretty odd behaviour. When I move mouse over from upside down, nothing happens. In opposite direction, all touched rows get underlined and stay that way until I move mouse over in some other direction. I am pretty confused by this. I wanted to stay out of jquery for simplicity, but with jquery I get the same result. Here is the code..

<div class="information" >
    <table id="summary" >
    <%
        foreach (KeyValuePair<long, float> pair in sums)
        { %>
            <tr>
                <td class="left" >Automat id: <%= pair.Key%></td>
                <td class="right" ><%= pair.Value%></td>
            </tr>
     <% } %>
    </table>
</div>

And the css applied to this div:

table
{
    border-collapse: collapse;
    border-spacing: 0;
    text-align: center;
    margin-top:.5em;
}

div.information
{
    margin:1em 0;
    padding:1em;
    font-weight:bold;
    text-align: center;
    color:#C80;
    background-color:#FF9;
    border:1px solid #C80;
}

#summary
{
    width: 715px;
    margin-bottom: 5px;
}

.left
{
    text-align: left;
}

.right
{
    text-align: right;
}

And the faulty part:

#summary tr:hover
{
    border-bottom: dotted 1px gray;
}

Anyone sees an error? Another way? And sorry for the long post.

A: 

Try using JavaScript onmouseover and onmouseout events. In this events just apply and un-apply your css class.

Bhaskar
So I tried it and I am still getting the weird behaviour.
Trimack
See this --> http://www.rgagnon.com/jsdetails/js-0093.html
Bhaskar
Instead of colour...just create two JS functions, and call them in onmouseover/out events. In the JS cals.....u just say..style = text-decoration:none;
Bhaskar
A: 

This looks like a bug in chrome. It works well on Firefox, and not at all in IE.
(IE doesn't support :hover, border-spacing, border for collapsed <tr>s, it goes on and on...)

I've found a simple workaround for Chrome, however - simply add a bottom border for all <tr>s:

#summary tr {
  border-bottom:solid 1px #FF9;
}

This will also keep your rows from changing heights and jiggle.

Kobi
It seems you are right about the bug. Opera works as described, Firefox doesnt work at all, Chrome a little better, but still wrong and IE is complete disaster.Unfortunatelly, I wanted the page a little dynamic.. but that work.. except for IE.
Trimack
I've tested it with the new bottom border, and it seems to work well on FF and Chrome. Strange it isn't working for you... Maybe you're on betas?
Kobi
A: 

Ok, there seems to be a bug in the way the :hover pseudoselector is being applied to "tr". Change selector to "#summary td:hover {}". It should work.

Crimson
Well, yes, it does, but it doesnt underline the whole row, but just half of it.
Trimack
half as in both the halves? - If this is the case, declare padding:0
Crimson
If I underline a cell and a row has two cells, the whole row won't be underlined. Only half of it.
Trimack
You can also try `#summary tr:hover td`, but then the line is broken (two lines for two cells), and Chrome is still twitchy.
Kobi