#Can someone guide me how to make this form next to the clicked btn?

6 messages · Page 1 of 1 (latest)

daring whale
#

i figured it is a modal form pop up. my question is how to make it appear next to the clicked item? i dont want it to be centered to the screen like modal alert.

Had trouble posting the video. so i did my best to highlight the question

iron flower
#

Try with position: fixed;

toxic python
daring whale
toxic python
#

Here's an example


const button = document.querySelector('#my-button');
const modal = document.querySelector('#modal');
button.addEventListener('click', function() {
  
  modal.style.position = 'absolute';

  
  // Position the modal card element
  const buttonRect = button.getBoundingClientRect();
  modal.style.top = buttonRect.top + buttonRect.height + 'px';
  modal.style.left = buttonRect.left + 'px';
  
  
 
});