超链接悬停时不改变颜色
我试图做到这一点,当用户将鼠标悬停在背景颜色上时会发生变化。问题是,在我完成所有设置后,只有我的标题改变了背景颜色,没有其他。
<tr>
<td class="near">
<a href="../index.html"class="near_place">
<img class="related_photo" />
<h4 class="nearby"> adfadfad </h4>
<span class="related_info">asdfadfadfaf</span>
</a>
...
CSS:
a.near_place {
width: 200px;
height: 65px;
border: none;
background: #fff;
display: inline;
}
a.near_place:hover {
background: #DEDEDE;
}
h4.nearby {
width: 150px;
margin-top: -2px;
margin-bottom: 3px;
font-size: 12px;
font-weight: normal;
color: #000;
display: inline;
}
img.related_photo {
width: 80px;
height: 60px;
border: solid thin #DFDFDF;
margin-right: 3px;
float: left;
overflow: hidden;
}
span.related_info {
width: 150px;
height: 54px;
font-size: 11px;
color: #666;
display: block;
}
td.near {
width: 25%;
height: auto;
}
任何帮助表示赞赏
I'm trying to make it so when a user hovers over the background color changes. The problem is that after I set it all up, only my header is changing the background color, nothing else.
<tr>
<td class="near">
<a href="../index.html"class="near_place">
<img class="related_photo" />
<h4 class="nearby"> adfadfad </h4>
<span class="related_info">asdfadfadfaf</span>
</a>
...
CSS:
a.near_place {
width: 200px;
height: 65px;
border: none;
background: #fff;
display: inline;
}
a.near_place:hover {
background: #DEDEDE;
}
h4.nearby {
width: 150px;
margin-top: -2px;
margin-bottom: 3px;
font-size: 12px;
font-weight: normal;
color: #000;
display: inline;
}
img.related_photo {
width: 80px;
height: 60px;
border: solid thin #DFDFDF;
margin-right: 3px;
float: left;
overflow: hidden;
}
span.related_info {
width: 150px;
height: 54px;
font-size: 11px;
color: #666;
display: block;
}
td.near {
width: 25%;
height: auto;
}
Any help is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要
background-color: #DEDEDE;
“-color”很重要
You need
background-color: #DEDEDE;
that "-color" is important
在 css 中看不到任何对背景以外的任何内容的引用,因此您想要更改的任何内容都需要用颜色指定
don't see any reference in css to anything other than background so whatever you want to change needs to be specified with a color
更具体的规则可能会有所帮助,例如尝试更改标签内标签的样式:
或者
More specific rules might help, for instance try changing style for tags inside of your tag:
Or
您犯了将 (a) 块元素和 (b) 浮动元素包装在内联元素内的错误。尝试将
元素更改为
display:block;
。You're committing the sin of wrapping (a) a block element and (b) a floating element inside an inline element. Trying changing your
<a>
element todisplay:block;
.