鼠标悬停在行上 (tr) 应用 tr:hover 规则,但如果鼠标悬停在 tr 输入子文本内容上,则应用 tr:hover 规则。
我只在 IE-8 中遇到过这个问题。谁能帮我找出根本原因。
备注:Jsfiddle
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="x-ua-compatible" content="IE=8" >
<html>
<head>
<meta charset="utf-8">
<style type="text/css" media="screen">
tr{
border-width: 0;
margin: 0;
padding: 0;
background-color: transparent;
line-height: 23px;
height: 23px;
vertical-align: middle;
cursor: pointer;
}
table {
border: 1px solid #d3deed;
border-collapse: collapse;
table-layout: fixed;
position: relative;
border-spacing: 0;
width: 100%;
}
table thead tr {
position: relative;
}
table th,
table thead td,
table tfoot td {
border-width: .08em;
padding: 2px;
height: 16px;
}
table tbody td {
border: 1px solid #d3deed;
border-bottom-color: #d3deed;
border-top-color: #d3deed;
}
table th {
border: 1px solid #d3deed;
border-top: 0;
border-bottom: .24em solid #d3deed;
border-bottom: .24em solid #d3deed;
background-color: #e5edf5;
color: #696969;
font: bold 12px/1.5 'Lucida Grande', Tahoma, sans-serif;
}
table input{
border-style: solid;
background-color: transparent!important;
border: 0;
font: normal 12px/1.5 Arial,Helvetica,sans-serif;
width: 100%;
cursor: text;
height: 1.4em;
left: 0;
position: relative;
top: 0;
vertical-align: middle;
border-radius: 0;
-moz-border-radius: 0;
}
table tr:hover {
background-color: green!important;
}
</style>
</head>
<body>
<table>
<caption>Row hover</caption>
<thead>
<tr>
<th>header1</th>
<th>header2</th>
<th>header3</th>
<th>header4</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div>
<input readonly="true" type="text" name="" value="dsfsdfsdfsdfdsfsdfsdfsdfdsfds">
</div>
</td>
<td>
<div>
<input readonly="true" type="text" name="" value="dsfsdfsdfsdfdsfsdfsdfsdfdsfds">
</div>
</td>
<td>
<div>
<input readonly="true" type="text" name="" value="dsfsdfsdfsdfdsfsdfsdfsdfdsfds">
</div>
</td>
<td>
<div>
<input readonly="true" type="text" name="" value="dsfsdfsdfsdfdsfsdfsdfsdfdsfds">
</div>
</td>
</tr>
</tbody>
</table>
</body>
最佳答案
如果您放弃传统方法,请使用一些 jQuery:
$("tr").hover(
function() {
$(this).css('background-color','#0f0');
}
);
关于html - 使用 tr :hover css selector is not working in IE 8 (in case of *tr>td>div>input text* mouse hover action) 将样式应用于表行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30450830/