0

Class of .sibling-fade is applying correctly on hover of the selected <li> element, however, it is being applied before the mouse enters the bordered area. Please see GIF below for an example.

Example GIF

sibling-fade expanding beyong container

HTML

ul {
  margin: 0px;
  padding: 0;
}

li {
  list-style-type: none;
  display: table-row;
  height: 54px;
}

/* Sibling Fade */

.sibling-fade {
  pointer-events: none;
}

.sibling-fade > * {
  pointer-events: auto;
}

.sibling-fade > * {
  transition: opacity 150ms linear 100ms, ease-in-out 100ms;
}

.sibling-fade:hover > * {
  opacity: 0.4;
}

.sibling-fade > *:hover {
  opacity: 1;
  transition-delay: 0ms, 0ms;
}
<ul class="sibling-fade">
  <li><a href="one.html"><p class="title">Project One</p></a></li>
  <li><a href="two.html"><p class="title">Project Two</p></a></li>
  <li><a href="three.html"><p class="title">Project Three</p></a></li>
</ul>
Minal Chauhan
  • 6,025
  • 8
  • 21
  • 41
Serene
  • 31
  • 8

1 Answers1

1

If you inspect <li> you will see that its width and height not exactly fit with its content, there are a couple of things causing this issue;

  1. <p class="title"> has top and bottom margin by default, remove it.
  2. You have to remove li {display: table-row;height: 54px;}.

All of these are calculated with the element width and height.

So what I have done after doing the above steps:

  1. add li {display: inline-block;}
  2. add <br> after each <li>

ul {
  margin: 0px;
  padding: 0;
}

li {
  list-style-type: none;
  display: inline-block;
}

/* Sibling Fade */

.sibling-fade {
  pointer-events: none;
}

.sibling-fade > * {
  pointer-events: auto;
}

.sibling-fade > * {
  transition: opacity 150ms linear 100ms, ease-in-out 100ms;
}

.sibling-fade:hover > * {
  opacity: 0.4;
}

.sibling-fade > *:hover {
  opacity: 1;
  transition-delay: 0ms, 0ms;
}
.title {
  margin: 0;
}
<ul class="sibling-fade">
  <li><a href="one.html"><p class="title">Project One</p></a></li><br>
  <li><a href="two.html"><p class="title">Project Two</p></a></li><br>
  <li><a href="three.html"><p class="title">Project Three</p></a></li><br>
</ul>
Mhd Alaa Alhaj
  • 2,438
  • 1
  • 11
  • 18