将鼠标悬停在图像上时,使h2文本加下划线

时间:2015-03-16 22:03:04

标签: html css alignment

jsfiddle.net/pxojrb1o /

您好,

当你将鼠标悬停在绿色图片上时,我正试着让“复古产品”文字下划线。如果我将绿色图片放在h2标签中,它会不对齐。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

HTML:我在h2中添加了一个类

<h2 class="products"><a href="products.html">retro products</a></h2>

CSS

.home-featured-class:hover .products {
    text-decoration: underline;
}

http://jsfiddle.net/pxojrb1o/3/

有关详细信息,请参阅此主题:How to affect other elements when a div is hovered

相关问题