[英]Hover over one div, effect the opacity of an image in another div (with jquery)
[英]Zoom effect on hover with image opacity
我使用了整個div上的鏈接進行圖像放大,但是沒有不透明度。 在第14-16行中添加此代碼后,由於明顯的原因,它停止工作:
background-color: rgba(0,0,0,0.4);
width: 100%;
height: 100%;
的HTML
<div class="zoom-group">
<a class="zoom-link" href="#" >
<div class="zoom-block">
<img src="http://placehold.it/250x250" />
<div class="zoom-text">
Hello
</div>
</div>
</a>
</div>
CSS:
.zoom-group{
overflow:hidden;
border: 1px solid #000000;
display: block;
position: relative;
text-align: center;
height: 250px;
width: 250px;
}
.zoom-text {
position: absolute;
bottom: 0px;
left: 0px;
background-color: rgba(0,0,0,0.4);
width: 100%;
height: 100%;
}
.zoom-block img{
max-width: 100%;
-webkit-transition: all 1s ease; /* Safari and Chrome */
-moz-transition: all 1s ease; /* Firefox */
-ms-transition: all 1s ease; /* IE 9 */
-o-transition: all 1s ease; /* Opera */
transition: all 1s ease;
}
.zoom-link {
display: block;
}
.zoom-block img:hover{
-webkit-transform:scale(1.25); /* Safari and Chrome */
-moz-transform:scale(1.25); /* Firefox */
-ms-transform:scale(1.25); /* IE 9 */
-o-transform:scale(1.25); /* Opera */
transform:scale(1.25);
}
我應該如何做這項工作? 我確實需要不透明層和放大功能以及整個div才能單擊。
img:hover
不會發生重疊DIV的原因。
定位到整個父對象,而不是遍歷圖像:
只需將您的最后一條語句從更改為.zoom-block img:hover{
.zoom-group:hover img{
.zoom-group{ overflow:hidden; border: 1px solid #000000; display: block; position: relative; text-align: center; height: 250px; width: 250px; } .zoom-text { position: absolute; bottom: 0px; left: 0px; background-color: rgba(0,0,0,0.4); width: 100%; height: 100%; } .zoom-block img{ max-width: 100%; -webkit-transition: all 1s ease; /* Safari and Chrome */ -moz-transition: all 1s ease; /* Firefox */ -ms-transition: all 1s ease; /* IE 9 */ -o-transition: all 1s ease; /* Opera */ transition: all 1s ease; } .zoom-link { display: block; } .zoom-group:hover img{ /**/ -webkit-transform:scale(1.25); /* Safari and Chrome */ -moz-transform:scale(1.25); /* Firefox */ -ms-transform:scale(1.25); /* IE 9 */ -o-transform:scale(1.25); /* Opera */ transform:scale(1.25); }
<div class="zoom-group"> <a class="zoom-link" href="#" > <div class="zoom-block"> <img src="http://placehold.it/250x250" /> <div class="zoom-text"> Hello </div> </div> </a> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.