I have been struggling with this for a few hours now, I have rewritten the css with everything that I can think of, but still nothing.
Basically I made a simple photo grid with a < ul > in which each < li > holds an image that is supposed to be 12.5% of the width of the parent element so I get 8 pictures per row. The pictures have an opacity of .2 and change to 1 when hovered.
It sounds super easy, and when I thought of it, I didn't consider spending more than a couple of minutes, but it was not the case.
The problem is that the elements change their ratio by 1px when hovered so I get 186 x 187, and so on. This causes a margin of 1px and it is really annoying because it also makes the images shake a bit.
It seems that it happens more when the width of the browser is smaller.
Right now, this is the structure that I was testing (I know, I didn't want the empty div.. It has a solution that someone else suggested.)
<section id="home" class="group">
<img class="intro" src="img/home.png">
<div id="bg">
<li>
<img class="bcg" src="img/0.jpg">
<div class="cambia" style="background: url(img/01.jpg)"></div>
</li>
</ul>
</div>
The < li > is the main container, the .bcg img is a transparent button that I placed to hover since I have one more element between the background and the buttons, so I have 3 z-index levels
.intro{
width: 36%;
border-radius: 99% 78% 34% 17%;
position: absolute;
display: block;
margin: 1% 31%;
z-index: 10;}
#home ul{
width: 110%;
position: relative;
left: -3%;
background: white;
padding-bottom: 36%}
#home li{
float: left;
overflow: hidden;
position: relative;
width: 12%;
padding-bottom: 12%;}
.box{
left: 0px;
top: 0px;
overflow: hidden;
position: absolute;}
.cambia{
width: 100%;
opacity: .25;
position: absolute;
z-index: 1;
padding-bottom: 100%;
background-size: cover!important;
transition: .4s ease-in-out .09s;}
.bcg{
position: absolute!important;
opacity: .0!important;
background: red;
z-index: 30!important;
width: 100%;}
.bcg:hover ~ .cambia{
opacity: 1!important;}