Guest User

Untitled

a guest
Feb 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  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. })
Add Comment
Please, Sign In to add comment