简体   繁体   English

多个悬停状态存在问题-不知道是相邻选择器还是同级选择器?

[英]Problems with multiple hover states - not sure if adjacent or sibling selectors?

It's always the little thing that get me unstuck. 总是让我不解的小事。 I'm trying to make a hover on a navigation element effect 3 elements. 我试图将鼠标悬停在导航元素效果3个元素上。 The background colour, the text colour, and the small arrow below the text. 背景颜色,文本颜色和文本下方的小箭头。

The background colour is easy enough, but the text colour only changes when you hover over the actual text - not the whole block element (framed by the background colour). 背景颜色很容易,但是只有当您将鼠标悬停在实际文本上时,文本颜色才会更改-而不是整个块元素(由背景颜色构成)。 Also, I wanted to image swap the little arrow beneath the text as well. 另外,我也想对文字下方的小箭头进行图像交换。 Example: 例:

在此处输入图片说明

Here is the site: 这是网站:

MACI test website MACI测试网站

I've read up on adjacent and sibling selectors - but I can't quite get it to do what i want. 我已经阅读了相邻的和同级的选择器-但是我无法完全按照自己的意愿去做。 It's probably really obvious, but I can't see it at the moment! 这可能确实很明显,但目前看不到! Any help would be appreciated :) 任何帮助,将不胜感激 :)

Put the coloring on the link instead of the li, and make the link a block element to fill up the li area: 将颜色放在链接上而不是li上,并使链接成为块元素以填充li区域:

ul.menu a {
    display:block;
    background-color:#FFFFFF;
}
ul.menu a:hover {
    background-color:#AE242A;
    color:#FFFFFF;
}

Also, you could put the arrow image as a non-repeating background image for the link, and set a different one for the regular link and the hover link. 另外,您可以将箭头图像作为链接的非重复背景图像,并为常规链接和悬停链接设置不同的箭头图像。

Another thought, have you tried: 另一个想法,您是否尝试过:

ul.menu li.nav-links:hover a.nav {
    color:#FFFFFF;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM