如何修复 CSS3 中工具提示的过渡?

How to fix transition on tooltips in CSS3?

我正在尝试向工具提示添加过渡效果 "container" 所以当我将鼠标悬停在容器上时,工具提示会显示。但是当我将鼠标悬停在工具提示本身上时它也会出现。我该怎么做才能停止工具提示上的悬停过渡效果,使其仅在我悬停在容器上时显示?

/*Styles for the tooltip container*/

.tooltip {
  margin-top: 5rem;
  height: 100px;
  width: 300px;
  background-color: aquamarine;
  padding: 1rem;
  cursor: pointer;
  text-transform: capitalize;
  font-size: 18px;
  text-align: center;
  line-height: 100px;
  position: relative;
}


/* Styles for the tooltip*/

.tooltip::before {
  content: attr(title);
  width: 200px;
  height: auto;
  font-size: 15px;
  color: #fff;
  background: #000;
  border-radius: 5px;
  padding: 10px;
  text-align: center;
  line-height: 30px;
  z-index: 2;
  opacity: 0;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  transition: opacity 0.4s ease-in-out;
}


/* Styles for the arrow*/

.tooltip::after {
  content: "";
  width: 0;
  height: 0;
  z-index: 2;
  opacity: 0;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #000;
  transition: opacity 0.4s ease-in-out;
}

.tooltip:hover::after,
.tooltip:hover::before {
  opacity: 1;
}
<div class="tooltip" title="Lorem ipsum dolor sit amet consectetur 
     adipisicing elit. Minima, ipsa.">tooltip</div>

只需要通过向伪元素添加 pointer-events: none; 来否定指针事件。干杯,欢迎来到 SO! :)

/*Styles for the tooltip container*/

.tooltip {
  margin-top: 5rem;
  height: 100px;
  width: 300px;
  background-color: aquamarine;
  padding: 1rem;
  cursor: pointer;
  text-transform: capitalize;
  font-size: 18px;
  text-align: center;
  line-height: 100px;
  position: relative;
}


/* Styles for the tooltip*/

.tooltip::before {
  content: attr(title);
  width: 200px;
  height: auto;
  font-size: 15px;
  color: #fff;
  background: #000;
  border-radius: 5px;
  padding: 10px;
  text-align: center;
  line-height: 30px;
  z-index: 2;
  opacity: 0;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  transition: opacity 0.4s ease-in-out;
  pointer-events: none;
}


/* Styles for the arrow*/

.tooltip::after {
  content: "";
  width: 0;
  height: 0;
  z-index: 2;
  opacity: 0;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #000;
  transition: opacity 0.4s ease-in-out;
}

.tooltip:hover::after,
.tooltip:hover::before {
  opacity: 1;
}
<div class="tooltip" title="Lorem ipsum dolor sit amet consectetur 
     adipisicing elit. Minima, ipsa.">tooltip</div>