【发布时间】:2014-05-17 15:54:01
【问题描述】:
在div 标记中,我有一个背景图像,在其下方还有一个文本链接。
背景图片和文字链接被包裹在同一个<a>标签中。
现在我要做的是在鼠标悬停在背景图像或文本链接上时更改文本链接的颜色。
到目前为止,我所做的只是在将鼠标悬停在文本上时仅更改文本颜色,但在将鼠标悬停在图像上时无法更改。
我应该在哪里应用悬停属性?尝试了数百种变化,但仍然无法做到。
这是测试演示:
http://jsfiddle.net/Bradg/65UHg/
还有代码,抱歉有点长。
EDIT更新了CSS代码并删除了一些与问题无关的行
CSS:
.make_cat_img_thumbnail {
display: inline-block;
max-width: 100%;
height: auto;
padding: 4px;
line-height: 1.428571429;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 7px;
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
text-decoration:none;
}
.text-center {
text-align: center;
}
.text-muted {
color: #999;
}
.text-muted:hover {
color: orange;
}
.c-cover-image {
width:120px;
height:120px;
background-size:100% 100%;
margin:auto;
background-repeat:no-repeat;
background-position:center center;
}
HTML:
<div class="make_catalogue" style="padding-top:10px;">
<div class="col-sm-3 col-xs-4 c-mobile c-mbottom">
<a href="google.com" class="make_cat_img_thumbnail">
<div style="background-image:url(../images/ctg/10085_1.jpg)" class="c-cover-image">
</div>
<br>
<p class="text-center text-muted">Some Text</p>
</a>
</div>
</div>
非常感谢!!!
【问题讨论】:
-
您的问题有点难以理解。您需要通过确切的 id 或类名指定
the text color when hover over the text。 -
当我将鼠标悬停在“Some Text”标签上方的背景图像上时,我需要指定文本颜色。
-
您需要不涉及 javascript 的纯 css 解决方案?
-
最好的解决方案是 CSS,为了保持简单,但如果无法通过 CSS 实现,则会寻找其他解决方案。你有什么简单的想法吗?