[英]How can I affect Opacity of an image whilst hovering a div?
I'm so so close to acheiving what I want... but I'm wondering if I've hit the limit of what is possible with css. 我是如此接近实现我想要的东西...但是我想知道我是否已经达到了CSS的极限。
If you navigate to http://host17.qnop.net/~gjcwebde/ecocamel/index.php?option=com_content&view=article&id=28&Itemid=49 如果您浏览到http://host17.qnop.net/~gjcwebde/ecocamel/index.php?option=com_content&view=article&id=28&Itemid=49
We have a product slider. 我们有一个产品滑块。 I'm trying to get it so that..
我正在努力做到这一点..
1) products start at 100% opacity on load. 1)产品从负载时的100%不透明度开始。 2) hover over a product.. and the one you are hovering over stays at 100% opacity, the others all go to say 0.5 opacity (dim down).
2)将鼠标悬停在一种产品上,然后将鼠标悬停在一种产品上,保持100%的不透明度, 而其他所有产品的透明度都将变为0.5 (降低)。
I have ALMOST achieved this with css. 我已经用CSS实现了ALMOST。 Yo can see it working, except, when you hover over the description that pops up... the active image goes back to 0.5 opacity.
除了将鼠标悬停在弹出的说明上时,您可以看到它正常工作...活动图像恢复为0.5透明度。 Is it possible to control the opacity of this image, whilst hovering over the popup description?
将鼠标悬停在弹出说明上时,是否可以控制该图像的不透明度? I really really hope so!
我真的很希望如此! Failing that... how might I acheive this with js?
失败了……我怎么能用js实现呢? Looked at some on here, but none really apply to my situation.
看着这里的一些东西,但没有一个真的适合我的情况。 Hope I've given enough information for you to understand.
希望我已经提供足够的信息供您理解。 Cheers!
干杯!
如果将任何包含div的鼠标悬停在#containingDiv:hover img { }
将会影响img,因此如果我是您,我会使用Ryan的解决方案,如果您将鼠标悬停在img上
This should work for the opacity on the images when the user is not hovering. 当用户不悬停时,这应该适用于图像的不透明度。
divName img {
opacity:0.3;
filter:alpha(opacity=30);(IE)
}
And then when they hover (this should include your product info styling to as you have that displayed when hovering.) 然后当它们悬停时(这应该包括您的产品信息样式,就像悬停时显示的样式一样。)
diveName img:hover{
opacity:1.0;
filter:alpha(opacity=100);(IE)
}
Also throw in an active class on start so that at least one product is being shown when the page loads 同时在启动时抛出活动类,以便在页面加载时至少显示一种产品
For example: 例如:
divName img .activeLoad{
opacity:1.0;
filter:alpha(opacity=100);(IE)
}
I picked up your html and put it in a fiddle. 我拿起你的html,放在小提琴中。 Take a look http://jsfiddle.net/hMW8N/
看看http://jsfiddle.net/hMW8N/
Anyway, this is all you basically need. 无论如何,这基本上就是您所需要的。 I'm over specifying with these selectors, but I'm doing it so you can better understand.
我已经用这些选择器指定了,但是我正在这样做,以便您更好地理解。
#slider-list-stick-1:hover .slide-index{
opacity: 0.5;
filter:alpha(opacity=50); //ie
}
#slider-list-stick-1 .slide-index:hover {
opacity: 1;
filter:alpha(opacity=100); //ie
}
Add to your styles this declaration 将此声明添加到您的样式中
.slide-index:hover img{
opacity: 1;
}
As other div
s are also in the slide-index
container - the hover
effect will still be applied. 由于其他
div
也位于slide-index
容器中- hover
效果仍将应用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.