I found this code on codepen and I have edited it quite a bit, but I am having trouble figuring out how to make the focused imaged on hover not transparent. Can anyone help me figure it out?
CSS:
<style>
* {
box-sizing: border-box;
}
body {
display: grid;
place-items: center;
min-height: 100vh;
}
ul {
display: flex;
width: calc(100% - 2rem);
padding: 0;
margin: 0;
list-style-type: none;
justify-content: center !important;
}
li {
padding: 0;
}
img {
max-width: 100%;
width: 100%;
object-fit: cover;
transition: all 0.2s ease;
}
ul:is(:hover, :focus-within) img {
filter: grayscale(calc(1 - var(--active-lerp, 0)));
}
:root {
--lerp-0: 1;
--lerp-1: 0.5787037;
--lerp-2: 0.2962963;
--lerp-3: 0.125;
--lerp-4: 0.037037;
--lerp-5: 0.0046296;
--lerp-6: 0;
}
a {
outline-offset: 4px;
}
li {
flex: calc(0.1 + (var(--active-lerp, 0) * 1));
transition: flex 0.2s ease;
}
li:is(:hover, :focus-within) {
--active-lerp: var(--lerp-0);
z-index: 7;
}
li:has( + li:is(:hover, :focus-within)),
li:is(:hover, :focus-within) + li {
--active-lerp: var(--lerp-1);
z-index: 6;
}
li:has( + li + li:is(:hover, :focus-within)),
li:is(:hover, :focus-within) + li + li {
--active-lerp: var(--lerp-2);
z-index: 5;
}
li:has( + li + li + li:is(:hover, :focus-within)),
li:is(:hover, :focus-within) + li + li + li {
--active-lerp: var(--lerp-3);
z-index: 4;
}
li:has( + li + li + li + li:is(:hover, :focus-within)),
li:is(:hover, :focus-within) + li + li + li + li {
--active-lerp: var(--lerp-4);
z-index: 3;
}
li:has( + li + li + li + li + li:is(:hover, :focus-within)),
li:is(:hover, :focus-within) + li + li + li + li + li {
--active-lerp: var(--lerp-5);
z-index: 2;
}
li:has( + li + li + li + li + li + li:is(:hover, :focus-within)),
li:is(:hover, :focus-within) + li + li + li + li + li + li {
--active-lerp: var(--lerp-6);
z-index: 1;
}
</style>
HTML:
<center>
<ul class="results">
<li class="result">
<a href="/wheins" target="_blank"><img src="https://static1.squarespace.com/static/61646d7cb4e28c4aa05e672d/t/65286d265b1cc2124d925ea9/1697148198679/WHeins+Pic.jpg" width="500" height="500" alt=""></a>
</li>
<li class="result">
<a href="/scutliff" target="_blank"><img src="https://static1.squarespace.com/static/61646d7cb4e28c4aa05e672d/t/65286d9eb52f32053f9d7ab5/1697148318606/SCutliff+Pic.jpg" width="500" height="500" alt=""></a>
</li>
<li class="result">
<a href="/jsale" target="_blank"><img src="https://static1.squarespace.com/static/61646d7cb4e28c4aa05e672d/t/652869b7ab9ddf1c543695d8/1697147319466/JSale+Pic.jpg" width="500" height="500" alt=""></a>
</li>
<li class="result">
<a href="/cvache" target="_blank"><img src="https://static1.squarespace.com/static/61646d7cb4e28c4aa05e672d/t/65286c0cdbaa5f53bd7cfb4a/1697147916652/CVache+Pic.jpg" width="500" height="500" alt=""></a>
</li>
<li class="result">
<a href="/jwilliams" target="_blank"><img src="https://static1.squarespace.com/static/61646d7cb4e28c4aa05e672d/t/65286c8657d1630d91e2fc96/1697148039037/JWilliams+Pic.jpg" width="500" height="500" alt=""></a>
</li>
</ul>
</center>
Last edited by a moderator: