skip to Main Content

Html – Can't get the element height for positioning an element to center by JavaScript

I am trying to center a span inside a paragraph using JavaScript. This is my code : document.addEventListener('DOMContentLoaded', () => { window.onload = function(){middle();} var titleHeight = document.getElementById("page-title").clientHeight; var titleWidth = document.getElementById("page-title").clientWidth; var objHeight = document.getElementById("head-text").clientHeight; var objWidth = document.getElementById("head-text").clientHeight;…

VIEW QUESTION
Back To Top
Search