0

I have a table where the data takes up two rows, so I am setting up a single row behavior across two rows. For example hover. The CSS below highlights two rows if the mouse enters via the top row, due to the:

table.table_form tbody tr.top:hover + tr

I need the reverse:

table.table_form tbody tr.bot:hover - tr

How do I do this?

So here is my CSS:

table.table_form tbody tr.bot:hover,
table.table_form tbody tr.top:hover,
table.table_form tbody tr.top:hover + tr {
  background: lighten($secondary, 10%);
  cursor: pointer;
}

And this HTML

<tr class="top-row " id="top6f3a4df1-1c3e-4453-9805-4ece86d504fc" data-pos="top" data-uuid="6f3a4df1-1c3e-4453-9805-4ece86d504fc">
        <th scope="col">
            <input class="table_input" type="text" value="SuperAdmin 1" data-orig="SuperAdmin 1">
        </th>
        <td>
            <input class="table_input" type="text" value="Australia" data-orig="Australia">
        </td>
        <td>
            <input class="table_input" type="text" value="Product" data-orig="Product">
        </td>
    </tr>
<tr class="bot-row bottom-border " id="bot6f3a4df1-1c3e-4453-9805-4ece86d504fc" data-pos="bot" data-uuid="6f3a4df1-1c3e-4453-9805-4ece86d504fc">
        <td>
            <input class="table_input" type="text" value="marclocchi13+1@gmail.com" data-orig="marclocchi13+1@gmail.com">
        </td>
        <td>
            <input class="table_input" type="text" value="" data-orig="">
        </td>
        <td colspan="2">
            <input class="table_input" type="text" value="" data-orig="">
        </td>
    </tr>
TheRealPapa
  • 4,393
  • 8
  • 71
  • 155

1 Answers1

1

There's no previous sibling CSS selector.

But you could simply re-structure the table so both input "rows" are actually inside a single td, and therefore, a single tr that can be highlighted on block.

input{
  width:100%;
}
<table>
  <tr id="top6f3a4df1-1c3e-4453-9805-4ece86d504fc" data-pos="top" data-uuid="6f3a4df1-1c3e-4453-9805-4ece86d504fc">
    <td>
      <input class="table_input" type="text" value="SuperAdmin 1" data-orig="SuperAdmin 1">
      <input class="table_input" type="text" value="marclocchi13+1@gmail.com" data-orig="marclocchi13+1@gmail.com">
    <td>
      <input class="table_input" type="text" value="Australia" data-orig="Australia">
      <input class="table_input" type="text" value="" data-orig="">
    </td>
    <td>
      <input class="table_input" type="text" value="Product" data-orig="Product">
      <input class="table_input" type="text" value="" data-orig="">
    </td>
  </tr>
  <tr id="top6f3a4df1-1c3e-4453-9805-4ece86d504fc" data-pos="top" data-uuid="6f3a4df1-1c3e-4453-9805-4ece86d504fc">
    <td>
      <input class="table_input" type="text" value="SuperAdmin 1" data-orig="SuperAdmin 1">
      <input class="table_input" type="text" value="marclocchi13+1@gmail.com" data-orig="marclocchi13+1@gmail.com">
    <td>
      <input class="table_input" type="text" value="Australia" data-orig="Australia">
      <input class="table_input" type="text" value="" data-orig="">
    </td>
    <td>
      <input class="table_input" type="text" value="Product" data-orig="Product">
      <input class="table_input" type="text" value="" data-orig="">
    </td>
  </tr>
</table>
Facundo Corradini
  • 3,825
  • 9
  • 24