Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.querySelectorAll("img[title]").forEach(img=> {
- const rect = img.getBoundingClientRect();
- const bodyRect = document.body.getBoundingClientRect();
- const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
- const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
- const $title = document.createElement('div');
- $title.innerText = img.title;
- $title.style.cssText = `
- position: absolute;
- top: ${scrollTop+rect.top+img.offsetHeight-bodyRect.top}px;
- left: ${scrollLeft+rect.left-bodyRect.left}px;
- background: #eeeeee;
- width: ${img.offsetWidth}px;
- padding: 1rem;
- box-sizing: border-box;
- z-index: 10000;
- `;
- document.body.append($title);
- })
Add Comment
Please, Sign In to add comment