@infinite-canvas-tutorial/webcomponents
Version:
WebComponents UI implementation
18 lines • 568 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.measureHTML = measureHTML;
function measureHTML(html) {
const div = document.createElement('div');
div.style.position = 'absolute';
div.style.visibility = 'hidden';
div.style.whiteSpace = 'nowrap'; // 如果你想单行测量
div.innerHTML = html;
document.body.appendChild(div);
const rect = {
width: div.offsetWidth,
height: div.offsetHeight,
};
document.body.removeChild(div);
return rect;
}
//# sourceMappingURL=html.js.map