Home > Web Front-end > JS Tutorial > JavaScript Box Model Dimensions In-depth Understanding_Basic Knowledge

JavaScript Box Model Dimensions In-depth Understanding_Basic Knowledge

WBOY
Release: 2016-05-16 17:44:50
Original
980 people have browsed it

Concept

Quoted from Wikipedia: According to CSS1 issued by the World Wide Web Consortium (W3C) in 1996 and revised in 1999, when the width or height of any block-level element is explicitly specified, it should only determine this The width or height of the visible element itself (the content area), and padding, border and margin are then applied. Internet Explorer in "weird mode" wraps content, padding, and borders within a specified width or height; this causes it to render a result that is narrower or taller than if it followed standard behavior. Short box. As shown below:

299px-W3C_and_Internet_Explorer_box_models.svg

Apply

Understanding the box model is very helpful whether it is setting the outer margin, border, padding of an element, the accurate application of height and width CSS styles, or using JavaScript to calculate the width and height of the box. For example, the outerWidth, innerWidth, and width provided in jQuery. With the above picture, you can clearly understand the accurate information of this value at any time, which is very useful when calculating the position and size of an element.

It is useful for applications in pop-up layers, dynamically adjusting the pop-up layer size, and calculating the maximum range of margins during dragging.

One picture to understand:

jquery-box-size

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template