<div class="tooltip">Anchor me!</div>
<a class="anchor">The anchor</a>
@import "https://unpkg.com/open-props/open-props.min.css";
@import "https://unpkg.com/open-props/normalize.min.css";
* {
box-sizing: border-box;
}
body {
font-family: "Google Sans", sans-serif;
min-height: 100vh;
background: var(--surface-2);
color: var(--text-1);
}
:root {
--anchor-width: 120px;
--anchor-top: 40vh;
--anchor-left: 20vmin;
}
.anchor {
position: absolute;
top: var(--anchor-top);
left: var(--anchor-left);
width: var(--anchor-width);
}
.tooltip {
position: absolute;
top: calc(var(--anchor-top));
left: calc((var(--anchor-width) * 0.5) + var(--anchor-left));
transform: translate(-50%, calc(-100% - 10px));
border: 1px solid var(--surface-3);
}
.tooltip {
box-shadow: var(--shadow-4);
padding: var(--size-4);
white-space: nowrap;
border-radius: var(--radius-2);
font-weight: var(--font-weight-6);
background: var(--surface-1);
}
.anchor {
background: var(--blue-4);
text-align: center;
font-weight: bold;
border-radius: var(--radius-2);
padding: var(--size-2);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.