当主DIV悬停时,更改链接颜色

发布于 2025-01-19 02:59:43 字数 1111 浏览 3 评论 0原文

我的问题是,当我将鼠标悬停在 div 上时,它不会将链接颜色更改为我想要的颜色。它只是保留其定义的默认黑色。但是当我直接将鼠标悬停在 div 中的链接上时,链接会改变颜色。

如何才能使当我将鼠标悬停在主 div 上时,它会更改 div 中链接的颜色?

链接到我的网站:https://www.temporary-url.com/CF16F6 尾巴:更多新闻

我有如下代码:

div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3):hover a
{
     color: #CB701A;  
}

/* unvisited link */

div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3) > a:link
{
  color: #333333;
}

/* visited link */
div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3) > a:visited
{
  color: #CB701A;
}

/* selected link */
div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3) > a:active 
{
  color: #333333;
}

/* mouse over link */
div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3) > a:hover
{
  color: #CB701A;
}

my issue is that, when I hover over my div, it doesn't change the links color to what I want it to be. It just stays its default black color as it is defined. But when I hover on link directly in div then link change color.

How can I make it so that when I hover over main div, it changes the color of the link inside in div?

Link to my website: https://www.temporary-url.com/CF16F6
tail: more news

I have code like below:

div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3):hover a
{
     color: #CB701A;  
}

/* unvisited link */

div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3) > a:link
{
  color: #333333;
}

/* visited link */
div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3) > a:visited
{
  color: #CB701A;
}

/* selected link */
div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3) > a:active 
{
  color: #333333;
}

/* mouse over link */
div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3) > a:hover
{
  color: #CB701A;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

路还长,别太狂 2025-01-26 02:59:43

您想要将 :hover 属性放在 div 上而不是 a 标记上

/* mouse over link */
div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3):hover > a
{
  color: #CB701A;
} 

you want to place the :hover attribute on the div rather than the a tag

/* mouse over link */
div.zsm_block_news > div.zsm_block_content > div:nth-child(2) > div:nth-child(3) > p:nth-child(3):hover > a
{
  color: #CB701A;
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文