Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
How to highlight all cells in row on mouse over in CSS Grid (display:grid)

I have a CSS grid:

.grid {
    display: grid;
    grid-template-columns: 10em 10em;
    grid-template-columns: 10em 10em;
    overflow: auto;
    width: 19em;
    height: 8em;
}
.grid-cell {
   border: solid 1px;
   height: 3em;
}
<div class="grid">
  <div class="grid-cell" data-row-index="0">A1</div>
  <div class="grid-cell" data-row-index="0">A2</div>

  <div class="grid-cell" data-row-index="1">B1</div>
  <div class="grid-cell" data-row-index="1">B2</div>

  <div class="grid-cell" data-row-index="2">C1</div>
  <div class="grid-cell" data-row-index="2">C2</div>
</div>

Is it possible to highlight all cells of a hovered row without dynamically modifying the cell element's attributes?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Here's a solution using a table instead of a grid.

.grid {
  width: 19em;
  height: 8em;
  overflow: auto;
}
table {
  border-collapse: collapse;
  width: 20em;
}
tr:hover {
  background-color: yellow;
}
td {
  border: solid 1px;
  height: 3em;
}
<div class="grid">
  <table>
    <tr>
      <td>A1</td>
      <td>A2</td>
    </tr>
    <tr>
      <td>B1</td>
      <td>B2</td>
    </tr>
    <tr>
      <td>C1</td>
      <td>C2</td>
    </tr>
  </table>
<div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!