Retour

Prévisualisation

Alerts users to save their progress before leaving a page

HTML
<div class="bni-tooltip-container">
  <div class="bni-icon">
    <svg
      xmlns="http://www.w3.org/2000/svg"
      viewBox="0 0 24 24"
      width="50"
      height="50"
    >
      <path
        d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm0 22c-5.518 0-10-4.482-10-10s4.482-10 10-10 10 4.482 10 10-4.482 10-10 10zm-1-16h2v6h-2zm0 8h2v2h-2z"
      ></path>
    </svg>
  </div>
  <div class="bni-tooltip">
    <p>Alerts users to save their progress before leaving a page</p>
  </div>
</div>
CSS
.bni-tooltip-container {
  position: relative;
  display: inline-block;
  margin: 20px;
}

.bni-icon {
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition:
    transform 0.3s ease,
    filter 0.3s ease;
}

.bni-icon svg {
  transition: transform 0.5s ease-in-out;
}

.bni-icon:hover svg {
  transform: rotate(360deg) scale(1.2);
}

.bni-tooltip {
  visibility: hidden;
  width: 200px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 5px;
  padding: 10px;
  position: absolute;
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition:
    opacity 0.5s,
    transform 0.5s;
  transform: translateY(10px);
}

.bni-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}

.bni-tooltip-container:hover .bni-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

@keyframes bni-bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-30px);
  }
  60% {
    transform: translateY(-15px);
  }
}

.bni-tooltip-container:hover .bni-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  animation: bni-bounce 0.6s ease;
}

License MIT

Original author: 3HugaDa3

Copyright - 2025 3HugaDa3 (Daniil) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.