Jump to content

Template:Tooltip/styles.css: Difference between revisions

From Insurer Brain
Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Wrapper */
/* {{pp-template}} */
.tooltip { position: relative; display: inline-block; }


/* Base: keep desktop exactly the same */
/* Term */
.tooltip-target { cursor: help; }
.tooltip { position: relative; display: inline; }
.tooltip-dotted { border-bottom: 1px dotted; cursor: help; }


/* --- Mobile-only synthesized tooltip (no pointer-events used) --- */
/* Dotted underline (sanitiser-safe) */
@media (hover: none) and (pointer: coarse) {
.tooltip-dotted .tooltip-target {
text-decoration: none;
border-bottom: 1px dotted currentColor;
}


/* Bubble text pulled from the existing title attribute */
/* Popup */
.tooltip .tooltip-body {
.tooltip[title]::after {
content: attr(title);
position: absolute;
left: 0;
position: absolute;
top: 100%;
left: 50%;
bottom: calc(100% + 8px);
margin-top: 6px;
transform: translateX(-50%);
padding: 6px 8px;
background: #222;
z-index: 1000;
color: #fff;
border-radius: 6px;
font-size: 0.875em;
line-height: 1.35;
max-width: 90vw;
box-shadow: 0 8px 24px rgba(0,0,0,.25);
z-index: 1000;


background: rgba(0,0,0,0.85);
opacity: 0;
visibility: hidden;
color: #fff;
padding: 6px 8px;
transform: translateY(3px);
border-radius: 4px;
}
box-shadow: 0 2px 6px rgba(0,0,0,0.3);
line-height: 1.2;
font-size: 0.875em;
max-width: 26rem;
white-space: normal;
text-align: left;


opacity: 0;
/* Show on hover and on focus (no :focus-within) */
visibility: hidden;
.tooltip:hover .tooltip-body,
}
.tooltip .tooltip-target:focus ~ .tooltip-body,
.tooltip a:focus ~ .tooltip-body,
.tooltip .tooltip-toggle:focus ~ .tooltip-body {
opacity: 1;
visibility: visible;
transform: translateY(0);
}


/* Arrow */
/* “ⓘ” toggle for link case (span, not <button>) */
.tooltip .tooltip-toggle {
.tooltip[title]::before {
margin-left: .25em;
content: "";
position: absolute;
padding: 0 .25em;
border: 0;
left: 50%;
bottom: calc(100% + 2px);
background: none;
transform: translateX(-50%);
font: inherit;
border: 6px solid transparent;
line-height: 1;
border-top-color: rgba(0,0,0,0.85);
cursor: pointer;

color: inherit;
opacity: 0;
visibility: hidden;
}

/* Non-link: the <span> itself is focusable (tabindex=0) */
.tooltip:focus::after,
.tooltip:focus::before,
.tooltip:active::after,
.tooltip:active::before {
opacity: 1;
visibility: visible;
}

/* Link case: focus/active land on the surrounding <a> */
a:focus > .tooltip[title]::after,
a:focus > .tooltip[title]::before,
a:active > .tooltip[title]::after,
a:active > .tooltip[title]::before {
opacity: 1;
visibility: visible;
}
}
}


/* Reduced-motion users (nothing to transition here, so nothing needed) */
/* Basic focus ring (omit outline-offset) */
.tooltip-target:focus,
.tooltip .tooltip-toggle:focus {
outline: 2px solid #99c2ff;
}

Latest revision as of 17:29, 1 October 2025

/* {{pp-template}} */

/* Base: keep desktop exactly the same */
.tooltip { position: relative; display: inline; }
.tooltip-dotted { border-bottom: 1px dotted; cursor: help; }

/* --- Mobile-only synthesized tooltip (no pointer-events used) --- */
@media (hover: none) and (pointer: coarse) {

  /* Bubble text pulled from the existing title attribute */
  .tooltip[title]::after {
    content: attr(title);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    z-index: 1000;

    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    line-height: 1.2;
    font-size: 0.875em;
    max-width: 26rem;
    white-space: normal;
    text-align: left;

    opacity: 0;
    visibility: hidden;
  }

  /* Arrow */
  .tooltip[title]::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 2px);
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0,0,0,0.85);

    opacity: 0;
    visibility: hidden;
  }

  /* Non-link: the <span> itself is focusable (tabindex=0) */
  .tooltip:focus::after,
  .tooltip:focus::before,
  .tooltip:active::after,
  .tooltip:active::before {
    opacity: 1;
    visibility: visible;
  }

  /* Link case: focus/active land on the surrounding <a> */
  a:focus > .tooltip[title]::after,
  a:focus > .tooltip[title]::before,
  a:active > .tooltip[title]::after,
  a:active > .tooltip[title]::before {
    opacity: 1;
    visibility: visible;
  }
}

/* Reduced-motion users (nothing to transition here, so nothing needed) */