daily pastebin goal
50%
SHARE
TWEET

Untitled

a guest Feb 15th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. document.querySelectorAll("img[title]").forEach(img=> {
  2.   const rect = img.getBoundingClientRect();
  3.   const bodyRect = document.body.getBoundingClientRect();
  4.   const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
  5.   const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
  6.   const $title = document.createElement('div');
  7.   $title.innerText = img.title;
  8.   $title.style.cssText = `
  9.   position: absolute;
  10.   top: ${scrollTop+rect.top+img.offsetHeight-bodyRect.top}px;
  11.   left: ${scrollLeft+rect.left-bodyRect.left}px;
  12.   background: #eeeeee;
  13.   width: ${img.offsetWidth}px;
  14.   padding: 1rem;
  15.   box-sizing: border-box;
  16.   z-index: 10000;
  17.  `;
  18.   document.body.append($title);
  19. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top