我有一个输入框,当用户开始输入时,它将显示一个div,并列出他们可以选择的俱乐部列表。
我现在只是想给它添加一些样式,而且我的.clubLink:hover类有问题。
CSS:
<style>
.clubList { display: none; width: 250px; margin-top: -5px; margin-left: -4px; border: 1px solid; }
.clubLink { width: 240px; padding: 5px; }
a { text-decoration: none; color: black; font-size: 10px; }
a:hover { color: #FFFFFF; }
.clubLink:hover { background-color: #0066FF; color: #FFFFFF; }
</style>HTML/ColdFusion:
<table width="450" cellpadding="0" cellspacing="0" class="content">
<tr>
<th colspan="2" class="content">Club Select</th>
</tr>
<tr class="content2">
<td>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="left" class="content"><strong>Please Select a Club:</strong></td>
<td align="left"><input type="text" name="clubFilter" id="clubFilter" class="formItem"></td>
</tr>
<tr>
<td align="left"> </td>
<td align="left" class="content">
<div id="clubList" class="clubList">
<cfloop query="Variables.getClubs">
<div class="clubLink">
<span class="clubName"><a href="passwordreset.cfm?cid=#clubID#">#clubName#</a></span>
</div>
</cfloop>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>JQuery:
<script>
$('#clubFilter').bind("keyup", function() {
var text = $(this).val().toLowerCase();
var items = $(".clubName");
items.parent().hide();
items.filter(function () {
return $(this).text().toLowerCase().indexOf(text) > -1;
}).parent().show();
$('#clubList').css("display", "block");
});
</script>当我在过滤列表中的俱乐部记录div (clubLink类)上徘徊时,背景颜色会发生变化,但是字体颜色仍然是黑色的。
唯一一次字体更改为白色是当我实际悬停俱乐部名称和锚样式应用。
有人知道我哪里出问题了吗?
非常感谢
发布于 2014-04-28 14:00:14
使用
.clubLink:hover { background-color: #0066FF; color: #FFFFFF; }
.clubLink:hover a{color: #FFFFFF; } 发布于 2014-04-28 13:58:19
锚点应该有一个display:block值,以便在.clubLink元素上悬停时触发。
发布于 2014-04-28 14:02:01
您正在更改div字体的颜色,但是文本颜色是由a给出的,所以在悬停div时保持不变是有意义的。您想要做的是让a继承div的颜色。
http://jsfiddle.net/sY4Gf/
.clubList {
display: none;
width: 250px;
margin-top: -5px;
margin-left: -4px;
border: 1px solid;
}
.clubLink {
width: 240px;
padding: 5px;
color:red; /* for testing */
}
a {
text-decoration: none;
font-size: 10px;
color:inherit;
}
.clubLink:hover {
background-color: #0066FF;
color: #FFFFFF;
}https://stackoverflow.com/questions/23343021
复制相似问题