TAG
CSS
JavaScript
Result
Run
License
<h3>Please resize the viewport horizontally.</h3> <span id="myspan">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span> <h4 id="line"></h4> <p id="console"></p>
#console { color: #e66465; }
window.addEventListener("load", () => { const elSpan = document.querySelector("#myspan"); const elLine = document.querySelector("#line"); const elConsol = document.querySelector("#console"); window.addEventListener("resize", e => { let clientRects = elSpan.getClientRects(); let length = clientRects.length; elLine.textContent = `Total Line: ${length}`; let log = ""; for(let i = 0; i < length; i++) { log += `
x: ${clientRects[i].x} y: ${clientRects[i].y} left: ${clientRects[i].left} top: ${clientRects[i].top} right: ${clientRects[i].right} bottom: ${clientRects[i].bottom} width: ${clientRects[i].width} height: ${clientRects[i].height} `; } elConsol.innerText = log; }); let evtResize = new Event("resize"); window.dispatchEvent(evtResize); });
Console
expand_less
License
License
by DevDic
Close