CSS:checked - change< td>背景 [英] CSS :checked - change <td> background

查看:102
本文介绍了CSS:checked - change< td>背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CSS,可以根据以下内容更改整个< tr> background-color 是否检查< input type =checkbox>

With CSS, is it possible to change the background-color of an entire <tr> based on whether or not an <input type="checkbox"> is checked?

<table>
 <!-- This is the row I want to change the background of... -->
 <tr>
  <td>
   <!-- ...when this is checked -->
   <input type="checkbox" name="cb1" id="cb1" />
  </td>
  <td>Something 1</td>
 </tr>
</table>


推荐答案

正在分配此功能(请参阅:has()

Not currently, no. This functionality is being specced (see :has()), but it won't actually be available for public use for quite some time.

 /* Only matches TRs that contain checked INPUTs */
 tr:has(input:checked) {
  background:red;
 }

根据当前的编辑草案有效,但语法可能会更改,或者功能可能会在浏览器供应商开始实施之前完全删除。

这篇关于CSS:checked - change&lt; td&gt;背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆