[英]image hover effect issue
I'm trying to do an effect that when I pass the mouse over on a picture I want to show a black box that appears closing stay only a square in the middle where I want to place an icon of a search icon. 我试图做一个效果,当我将鼠标移到图片上时,我想要显示一个黑色的盒子,显示关闭只留在中间的一个正方形,我想放置一个搜索图标的图标。
I found a tutorial that explains how to do this, but it explains very lightly. 我找到了一个教程,解释了如何做到这一点,但它解释得很轻松。
I am having a problem because I wanted my picture have width:155px; 我遇到了问题,因为我希望我的照片有宽度:155px; and height:140px;.
和身高:140px;
But When I give this width and height values in .view {}
the square in the middle that I do not want to turn it black disappears, and I want that square visible to put icon search there. 但是当我在
.view {}
给出这个宽度和高度值时,我不想让它变黑的中间的正方形消失了,我希望那个正方形可以在那里放置图标搜索。 Maybe I´m not explained myself well, but I think with the jsFiddle you can understand my problem. 也许我没有很好地解释自己,但我认为使用jsFiddle你可以理解我的问题。 I wish you could help me, any help is welcome!
我希望你能帮助我,欢迎任何帮助!
My fiddle to better understand: 我更无法理解的小提琴:
http://jsfiddle.net/ritz/cQL4S/ http://jsfiddle.net/ritz/cQL4S/
My html: 我的HTML:
<div class="view second-effect">
<img src="images/image1.jpg" />
<div class="mask">
<a href="#" class="info">Read More</a>
</div>
</div>
My css: 我的css:
.view {
width: 225px;
height: 225px;
margin: 10px;
float: left;
border: 5px solid #fff;
overflow: hidden;
position: relative;
text-align: center;
box-shadow: 0px 0px 5px #aaa;
cursor: default;
}
.view .mask, .view .content {
width: 225px;
height: 225px;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
}
.view img {
display: block;
position: relative;
}
.view a.info {
background:url(../img/link.png) center no-repeat;
display: inline-block;
text-decoration: none;
padding:0;
text-indent:-9999px;
width:20px;
height:20px;
}
.second-effect .mask {
opacity: 0;
overflow:visible;
border:0px solid rgba(0,0,0,0.7);
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
.second-effect a.info {
position:relative;
top:-10px;
opacity:0;
-moz-transform:scale(0,0);
-webkit-transform:scale(0,0);
-o-transform:scale(0,0);
-ms-transform:scale(0,0);
transform:scale(0,0);
-webkit-transition: -webkit-transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
-moz-transition: -moz-transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
-o-transition: -o-transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
-ms-transition: -ms-transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
transition: transform 0.2s 0.1s ease-in, opacity 0.1s ease-in-out;
}
.second-effect:hover .mask {
opacity: 1;
border:100px solid rgba(0,0,0,0.7);
}
.second-effect:hover a.info {
opacity:1;
-moz-transform:scale(1,1);
-webkit-transform:scale(1,1);
-o-transform:scale(1,1);
-ms-transform:scale(1,1);
transform:scale(1,1);
-moz-transition-delay:0.3s;
-webkit-transition-delay:0.3s;
-o-transition-delay:0.3s;
-ms-transition-delay:0.3s;
transition-delay:0.3s;
}
My jsfiddle with the problem: 我的问题是:
http://jsfiddle.net/ritz/cQL4S/1/ http://jsfiddle.net/ritz/cQL4S/1/
When you resize the container, you will have to resize the hover as well. 调整容器大小时,还必须调整悬停大小。 The hover has a border of 100px.
悬停的边框为100px。 This is more than the container.
这不仅仅是容器。
http://jsfiddle.net/cQL4S/3/ http://jsfiddle.net/cQL4S/3/
.second-effect:hover .mask {
border:40px solid rgba(0,0,0,0.7);
}
Also becourse you're new size is not a square, the border is not a square. 另外,你的新尺寸不是正方形,边界不是正方形。
The position of the icon is wrong. 图标的位置是错误的。 http://jsfiddle.net/ritz/cQL4S/5/
http://jsfiddle.net/ritz/cQL4S/5/
.second-effect a.info {
top: 20px;
}
I made the background red so you can see. 我把背景变成红色,你可以看到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.