+ 2

How to bigger image when hover the images in gallery with css??

I create big gallery When I hover the image ,it is big but it's overlap with the another images and I use the z-index but it's not working...how to fix it? Thanks for helping me

19th Jul 2021, 4:50 AM
Sara012
Sara012 - avatar
11 RĂ©ponses
+ 2
I do not understand what you really mean with overlap. I runned your code on a smartphone and that works not so good. But if you make a hover image bigger this will always overlap another images. If you mean that another images overlap this image, which will be hovered, then you can set in the class „bigger“ a z-index: 9; z-index only works on positioned elements position: absolute, position: relative, position: fixed, or position: sticky and flex items
19th Jul 2021, 6:43 AM
JaScript
JaScript - avatar
+ 2
Thanks but my problem is When hover The image overlap with the another images... Can you fix this problem??
19th Jul 2021, 5:13 AM
Sara012
Sara012 - avatar
+ 2
sorry I can't tell my problem very well but you solve my problem Thanks
19th Jul 2021, 7:03 AM
Sara012
Sara012 - avatar
+ 1
I will try it...thanks https://codepen.io/bobbykorec/pen/bGqOZBY This link is grid gallery and I create my gallery like this but I want to effect when I hover the images it is bigger than the other images without overlap the other images my problem is overlap by the other images...
19th Jul 2021, 4:54 AM
Sara012
Sara012 - avatar
+ 1
<style> .bigger { padding: 40px; background-color: blue; transition: transform .3s; width: 100px; height: 150px; margin: 0 auto; } .bigger:hover { transform: scale(1.4); } </style> <div class="bigger"></div>
19th Jul 2021, 5:04 AM
JaScript
JaScript - avatar
+ 1
No problem Sara , You are welcome.
19th Jul 2021, 3:54 PM
JaScript
JaScript - avatar
0
Can you link your code here if possible?
19th Jul 2021, 4:52 AM
RKK
RKK - avatar
0
Try to put your image in a div container with a class. <style> .img-container{ overflow: hidden; } .img-container img{ width: 100%; height: 100%; object-fit: cover; transition: all 0.3s ease-out; cursor: pointer; } .img-container img:hover{ transform: scale(1.2); } </style> <div class="img-container"> <img src="image.jpg" /> </div>
20th Jul 2021, 3:12 PM
Ahnaf Tahmid Chowdhury
Ahnaf Tahmid Chowdhury - avatar
0
Thanks
20th Jul 2021, 3:14 PM
Sara012
Sara012 - avatar
0
I do not understand what you really mean with overlap. I runned your code on a smartphone and that works not so good. But if you make a hover image bigger this will always overlap another images. If you mean that another images overlap this image, which will be hovered, then you can set in the class „bigger“ a z-index: 9; z-index only works on positioned elements position: absolute, position: relative, position: fixed, or position: sticky and flex items
20th Jul 2021, 9:14 PM
Nasim
0
Try to put your image in a div container with a class. <style> .img-container{ overflow: hidden; } .img-container img{ width: 100%; height: 100%; object-fit: cover; transition: all 0.3s ease-out; cursor: pointer; } .img-container img:hover{ transform: scale(1.2); } </style> <div class="img-container"> <img src="image.jpg" /> </div>
20th Jul 2021, 9:14 PM
Nasim