yaparoff,
<!DOCTYPE html><html lang='en' class=''>
<head>
<meta charset="utf-8">
<style class="cp-pen-styles">.sidebar__block {
margin-top: 60px;
}
.sidebar__user-actions-status {
display: flex;
align-items: center;
font-size: 16px;
}
.sidebar__user-actions-status-loyal {
display: block;
width: 8px;
height: 8px;
margin-right: 8px;
border-radius: 6px;
cursor: pointer;
}
.sidebar__user-actions-status-loyal--good {
background-color: #2dc2bd;
}
.sidebar__user-actions-status-loyal--may-be-good {
background-color: #2DC2BD;
}
.sidebar__user-actions-status-loyal--not-good {
background-color: #E53D00;
}
.sidebar__user-actions-status-loyal-container {
position: relative;
display: flex;
align-items: center;
justify-content: space-around;
width: 20px;
height: 20px;
}
.sidebar__user-actions-status-text {
font-size: 16px;
line-height: 16px;
}
.sidebar__tooltip {
position: fixed;
left: -9999px;
visibility: hidden;
width: 320px;
z-index: 101;
background: #FFFFFF;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 10px rgba(0, 0, 0, 0.24);
opacity: 0;
transition: visibility 0s ease-out 0.3s, opacity ease-out 0.3s;
}
@media (max-width: 1024px) {
.sidebar__tooltip {
display: none;
}
}
.sidebar__tooltip--notifications {
top: 115px;
}
.sidebar__tooltip--notifications:after {
position: absolute;
display: block;
content: '';
top: -19px;
left: 30px;
border: 10px solid transparent;
border-bottom: 12px solid #ffffff;
}
.sidebar__tooltip--notifications .sidebar__tooltip-wrapper {
max-height: 360px;
padding: 15px 0 0;
}
.sidebar__tooltip--notifications-active {
left: 165px;
visibility: visible;
opacity: 1;
transition: visibility 0s linear 0s, opacity 0.3s ease-out;
}
.sidebar__tooltip--loyal {
z-index: 102;
}
.sidebar__tooltip--loyal:after {
position: absolute;
display: block;
content: '';
top: 15px;
left: -19px;
border: 10px solid transparent;
border-right: 12px solid #ffffff;
}
.sidebar__tooltip--loyal-active {
visibility: visible;
opacity: 1;
transition: visibility 0s linear 0s, opacity 0.3s ease-out;
}
</style></head><body>
<div class="sidebar__tooltip sidebar__tooltip--loyal">
<div class="sidebar__tooltip-wrapper">
<h3 class="sidebar__tooltip-title">Ваш статус: Благонадежный</h3>
<p class="sidebar__tooltip-text">Поставка шинной продукции в ваш адрес возможна на следующих условиях расчетов: 100% предварительная оплата или отсрочка платежа на условиях ценовой программы.</p>
</div>
</div>
<div class="sidebar__block">
<div class="sidebar__user-actions-status">
<div class="sidebar__user-actions-status-loyal-container">
<span class="sidebar__user-actions-status-loyal sidebar__user-actions-status-loyal--may-be-good"></span>
</div>
<span class="sidebar__user-actions-text">ООО «Шина»</span>
</div>
</div>
<script >
const tooltipLoyal = document.querySelector('.sidebar__tooltip--loyal');
const userActionsStatusLoyal = document.querySelector('.sidebar__user-actions-status-loyal');
function showInfoTooltipLoyal() {
console.log('show');
const topPosition = userActionsStatusLoyal.getBoundingClientRect().top;
const rightPosition = userActionsStatusLoyal.getBoundingClientRect().right;
tooltipLoyal.style.top = topPosition - 20 + 'px';
tooltipLoyal.style.left = rightPosition + 15 + 'px';
tooltipLoyal.classList.add('sidebar__tooltip--loyal-active');
}
function hideInfoTooltipLoyal() {
console.log('hide');
tooltipLoyal.classList.remove('sidebar__tooltip--loyal-active');
tooltipLoyal.removeAttribute('style');
}
let timer;
function timerEnd()
{
window.clearTimeout(timer)
}
userActionsStatusLoyal.addEventListener('mouseover', function (event) {
timerEnd();
showInfoTooltipLoyal();
});
userActionsStatusLoyal.addEventListener('mouseout', function () {
timerEnd();
timer = window.setTimeout(hideInfoTooltipLoyal, 100)
});
tooltipLoyal.addEventListener('mouseover', function (event) {
timerEnd();
showInfoTooltipLoyal();
});
tooltipLoyal.addEventListener('mouseout', function () {
timerEnd();
timer = window.setTimeout(hideInfoTooltipLoyal, 100)
});
</script>
</body></html>