Web Design

CSS

Assorted CSS Tricks and Tips

CSS Only Popover

<button type="button" id="popover_button" class="btn" popovertarget="popover">
Open popover
</button>
<div popover id="popover" class="popover" role="dialog">
<= render "dimensions form" %>
</div>
• popover {
  background-color: var(--color-surface);
  border-radius: var(--rounded-md); border-width: var(--border);
  box-shadow: var(--shadow-md);
  color: var(--color-text);
  inline-size: var(--popover-size, max-content); 
  
  /* Anchor position */ 
  position-area: block-end; 
  position-try-fallbacks: flip-block;
  margin-block-start: var(--size-1);
  
  /* Setup transition */
  transition-duration: var(--time-150);
  transition-property: display, opacity, overlay, transform;
  
  /* Exit stage to */
  opacity: 0; transform: var(--scale-95);
  
  /* On stage */
  &: popover-open {
    opacity: 1; transform: var(--scale-100);
  }

  /* Enter stage from */
  @starting-style {
    &: popover-open {
      opacity: 0; transform: var(--scale-95);
    }
  }
}
Lázaro Nixon's original post!

Pointer aware cards with hover blur effect

context aware cards w/ blur 👨‍🍳Original source: https://x.com/jh3yy/status/1992003440579662211?s=46

Stop mobile address bar from hiding UI

Use svh to stop the mobile address bar from hiding your UI. It guarantees a perfect fit within the visible screen.

.hero {
  height: 100svh;
}