全屏
<button popovertarget="my-popover" class="trigger-btn"> Open Popover </button>

<div id="my-popover" popover>
  <button class="close-btn" popovertarget="my-popover" popovertargetaction="hide">
    <span aria-hidden=”true”>❌</span>
    <span class="sr-only">Close</span>
  </button>
  <p>I am a popover with more information.<p>
</div>
.trigger-btn {
  background: #ddd;
  font-weight: 800;
  border: 2px solid black;
}

.close-btn {
  border: none;
  background: none;
  position: absolute;
  right: 0.25rem;
  top: 0.5rem;
  filter: grayscale() brightness(10);
}

#my-popover {
  background: #333;
  color: white;
  font-weight: 400;
  padding: 1rem;
  max-width: 200px;
  line-height: 1.4;
  position: absolute;
  top: 1rem;
  left: 0;
  right: 0;
  margin: 0 auto;
  padding-top: 2rem;
}

body {
  display: grid;
  font-family: system-ui, sans-serif;
  place-items: center;
  height: 100dvh;
}

.sr-only:not(:focus):not(:active) {
  clip: rect(0 0 0 0); 
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap; 
  width: 1px;
}
返回