[英]Image hover CSS for revolution slider
I'm using revolution slider and I'm stuck with a problem. 我正在使用旋转滑块,但遇到了问题。 As an example I use the original demo from here: https://revolution.themepunch.com/wordpress-photography-slider .
作为示例,我使用此处的原始演示: https : //revolution.themepunch.com/wordpress-photography-slider 。
On the tab 'portfolio' you see images that shrink in size with a transition and look a bit darker when you hover over them. 在“作品集”选项卡上,您看到的图像会随着过渡而缩小,而将鼠标悬停在其上方时,图像会显得更暗。 This is what I want as well but I can't figure out how.
这也是我想要的,但是我不知道怎么做。
In revolution slider you can add classes, ID's and CSS to specific images so what I probably need is a CSS code that makes this possible. 在Revolution滑块中,您可以将类,ID和CSS添加到特定的图像,因此我可能需要的是CSS代码,可以实现这一点。 I've tried several codes I found online but none of them do the trick because they all come with an html part as well.
我已经尝试过在网上找到的几个代码,但是没有一个能解决问题,因为它们都带有html部分。
My guess was: the image is already there, I don't need the html part, only assign classes or id's to the images and then give each image the same kind of CSS code. 我的猜测是:图像已经存在,我不需要html部分,只需为图像分配类或ID,然后为每个图像提供相同类型的CSS代码。
Am I on the right track with this? 我是否在正确的轨道上? And can anyone help me with the code for it?
有人可以帮我提供代码吗?
Many thanks in advance! 提前谢谢了!
add a class, then do some css 添加一个类,然后做一些CSS
for example: 例如:
<img class="slider-img">
.slider-img:hover {
{
let me know if you need help with the css. 让我知道您是否需要有关CSS的帮助。
EDIT: 编辑:
try this. 尝试这个。
wrap each of your images around 2 divs, slider-img and img-wrap: 将每个图像围绕2个div,slider-img和img-wrap包裹:
<div class="slider-img">
<div class="img-wrap">
<img src="http://science-all.com/images/wallpapers/stock-image/stock-image-15.jpg">
</div>
</div>
then do some css: 然后做一些CSS:
.slider-img {
width: 200px;
cursor: pointer;
}
.slider-img img {
width: 100%;
}
.slider-img:hover .img-wrap {
background-color: black;
transform: scale(0.7);
-o-transform: scale(0.7);
-ms-transform: scale(0.7);
-moz-transform: scale(0.7);
-webkit-transform: scale(0.7);
transition: all .5s ease-in-out;
-o-transition: all .5s ease-in-out;
-ms-transition: all .5s ease-in-out;
-moz-transition: all .5s ease-in-out;
-webkit-transition: all .5s ease-in-out;
}
.slider-img:hover .img-wrap img{
opacity: 0.5;
}
basically what the css is doing is that when you hover over the main div (.slider-img), the div containing the image (.img-wrap) gets scaled down by 70% by the css -webkit-transform: scale(0.7); 基本上,css所做的是,当您将鼠标悬停在主div(.slider-img)上时,包含图像(.img-wrap)的div将通过css -webkit-transform缩小70%:scale(0.7 );
it also gets a background color of black with an opacity of 80%. 它还具有不透明度为80%的黑色背景色。 this gives the darkened image effect.
这会产生暗淡的图像效果。
-webkit-transition: all .5s ease-in-out; -webkit-transition:所有.5s缓入; gives a smooth transition effect.
给出平滑的过渡效果。
if you are wondering why there are 5 different lines of css for the same thing, thats because each line targets specific browsers. 如果您想知道为什么同一事物有5条不同的CSS行,那是因为每一行都针对特定的浏览器。 -o- is opera, -moz- is firefox etc.
-o-是歌剧,-moz-是Firefox等。
also, make sure to change the .slider-img width to match your needs. 另外,请确保更改.slider-img宽度以符合您的需求。
check out the working example on js fiddle: 查看js小提琴上的工作示例:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.