【问题标题】:Change background color of entire row when tabbed?选项卡时更改整行的背景颜色?
【发布时间】:2018-08-24 07:01:06
【问题描述】:

我有一个两列五行的简单表格。我希望它更易于键盘访问。

左栏只是文本,右栏是在聚焦/悬停时填充的按钮。

有没有办法在选项卡(聚焦)时更改整行的背景颜色并同时填充按钮背景颜色?

【问题讨论】:

  • 码码码!你的代码在哪里??

标签: html-table focus background-color


【解决方案1】:

编辑:为focus添加

假设你有这样一张桌子:

<table style="width:100%">
  <tr class="hoverable-row">
    <th>Firstname</th>
    <th>Lastname</th> 
    <th>Age</th>
  </tr>
  <tr class="hoverable-row">>
    <td>Jill</td>
    <td>Smith</td> 
    <td>50</td>
  </tr>
  <tr class="hoverable-row">>
    <td>Eve</td>
    <td>Jackson</td> 
    <td>94</td>
  </tr>
</table>

然后在css中

.hoverable-row:hover, :focus { 
    background-color: yellow;
}

另外,请阅读https://stackoverflow.com/help/how-to-ask,了解如何以一种好的方式提问。

【讨论】:

  • 这样 CSS 在悬停时可以正常工作,但我需要在通过键盘访问时应用它?我将编辑主要问题,抱歉没有以最好的方式提问:D
猜你喜欢
  • 1970-01-01
  • 2019-08-06
  • 1970-01-01
  • 2017-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-22
相关资源
最近更新 更多