英文:
Change colour of elements inside an Elementor container on hover
问题
请查看此网站:https://reasone29.sg-host.com/
主要部分上的三个方框,比如'完整转换套餐',我想在鼠标悬停在容器上时更改元素(文本和按钮)的颜色。
我可以编写CSS以在直接悬停在元素上时更改颜色,但我希望当鼠标悬停在容器上并变为蓝色时,所有元素同时更改。
我尝试过各种CSS代码,但没有成功。
提前感谢。
各种CSS代码但没有结果:
.elementor-container:hover .elementor-element h1,
.elementor-container:hover .elementor-element h2,
.elementor-container:hover .elementor-element h3,
.elementor-container:hover .elementor-element h4,
.elementor-container:hover .elementor-element h5,
.elementor-container:hover .elementor-element h6 {
color: #ff0000 !important;
}
.elementor-container:hover .elementor-element h1,
.elementor-container:hover .elementor-element h2 {
color: #ff0000 !important;
}
我还尝试了标题的选择器,但仍然没有成功。
英文:
Please see this website: https://reasone29.sg-host.com/
The three boxes on the hero section, e.g. 'Full Conversion Packages', I want to change the colour of the elements (text and the button) when you hover over the container.
I can do CSS that changes the colour of the element when you hover over it directly, but I want it so all the elements change at the same time when you hover over the container and it turns blue.
I've tried various CSS codes but had no luck.
Thanks in advance.
Various CSS codes but no results:
.elementor-container:hover .elementor-element h1,
.elementor-container:hover .elementor-element h2,
.elementor-container:hover .elementor-element h3,
.elementor-container:hover .elementor-element h4,
.elementor-container:hover .elementor-element h5,
.elementor-container:hover .elementor-element h6 {
color: #ff0000 !important;
}
.elementor-container:hover .elementor-element h1,
.elementor-container:hover .elementor-element h2 {
color: #ff0000 !important;
I also tried the selector for the headings but still no luck.
答案1
得分: 0
我不确定你想要实现什么,因为你代码中使用的十六进制代码是红色而不是蓝色,正如你所指示的。不管怎样,你可以使用ID来使其生效。在包含所有3个方框的容器上使用ID "opt-container",然后在所有3个按钮元素上使用ID "opt-btn"。然后使用下面的代码,这将使所有3个方框和按钮的文本变为红色,而按钮的文本颜色保持为白色
悬停效果适用于所有3个方框
#opt-container:hover h3,
#opt-container:hover h6
{
color: #ff0000;
}
#opt-container:hover #opt-btn
{
background-color: #ff0000;
border-color: #ff0000;
color: #fff;
}
如果你想要整个方框在悬停时改变颜色,那么给每个3个容器添加ID "opt-box" 并使用下面的代码:
#opt-container:hover #opt-box
{
background-color: #26ABE2;
}
悬停效果适用于每个方框,分别
#opt-box-1:hover,
#opt-box-2:hover,
#opt-box-3:hover
{
background-color: #26ABE2;
}
下面的代码在悬停时改变字体颜色(h3和h6):
#opt-box-1:hover h3,
#opt-box-1:hover h6,
#opt-box-2:hover h3,
#opt-box-2:hover h6,
#opt-box-3:hover h3,
#opt-box-3:hover h6
{
color: #ff0000;
}
英文:
I'm not sure as to what you want to achieve because the hex-code you're using in your code is red and not blue, as you indicated.
Either way, you can use IDs to make this work. Use the ID "opt-container" on the container that holds all 3 boxes and then the ID "opt-btn" on all 3 button elements. Then use the code below and this should make the text of all 3 boxes red and the button too, while the text color of the button remains white
Hover effect applies to all 3 boxes at once
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
#opt-container:hover h3,
#opt-container:hover h6
{
color: #ff0000;
}
#opt-container:hover #opt-btn
{
background-color: #ff0000;
border-color: #ff0000;
color: #fff;
}
<!-- end snippet -->
If you want the entire box to change color on hover then you add the ID "opt-box" to each of the 3 containers and use the code below:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
#opt-container:hover #opt-box
{
background-color: #26ABE2;
}
<!-- end snippet -->
Hover effect applies to each box, individually
(In response to your comment:)
Use the 3 different IDs (classes would probably work too) for your boxes and call them "opt-box-1" "opt-box-2" and "opt-box-3". Also add the IDs (or classes) "opt-btn-1" "opt-btn-2" and "opt-btn-3". on the 3 button elements. Then use the code below to change the background on hover:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
#opt-box-1:hover,
#opt-box-2:hover,
#opt-box-3:hover
{
background-color: #26ABE2;
}
<!-- end snippet -->
The code below changes the font color (h3 and h6) on hover:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
#opt-box-1:hover h3,
#opt-box-1:hover h6,
#opt-box-2:hover h3,
#opt-box-2:hover h6,
#opt-box-3:hover h3,
#opt-box-3:hover h6
{
color: #ff0000;
}
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论