1. Offset series properties
< div id = "dv" ></ div > <!-- The width and height of the div have been set to 100px in the style tag --> < script > // The style attribute in the style tag cannot be obtained, but in the style attribute The set style can be obtained console.log(document.getElementById( " dv " ).style.width); // empty---cannot be obtained // So the offset series is introduced, and there are a total of four properties as follows: // 1. You can get the width of the element through offsetWidth console.log(document.getElementById( " dv " ).offsetWidth); // 100 // 2. You can get the height of the element through offsetHeight console.log(document.getElementById( " dv " ).offsetHeight); // 100 // 3. You can get the value of the element's distance to the left through offsetLeft // Note: // Not out of the document flow, value = margin and padding and border of the parent element + own margin // out of the document flow, value = your own left + yourself margin console.log(document.getElementById( " dv " ).offsetLeft); // 8--- not clear margin // 4. You can get the value of the element's distance from the top through offsetLeft console.log(document.getElementById( " dv " ).offsetTop); // 8---Not clear the margins // Note: // Not out of the document flow, Value = margin and padding and border of parent element + own margin // out of document flow, value = own left + own margin </ script >