There are several properties you can look at in order to determine the width and height of elements, and it can be tricky to determine which is the right one for your needs. This article is designed to help you make that decision.
If you need to know the total amount of space an element occupies, including the width of the visible content, scrollbars (if any), padding, and border, you want to use the HTMLElement.offsetWidth
and HTMLElement.offsetHeight
properties. Most of the time these are the same as width and height of Element.getBoundingClientRect()
, when there aren't any transforms applied to the element. In case of transforms, the offsetWidth
and offsetHeight
returns the element's layout width and height, while getBoundingClientRect()
returns the rendering width and height. As an example, if the element has width: 100px;
and transform: scale(0.5);
the getBoundingClientRect()
will return 50 as the width, while offsetWidth
will return 100.
HTMLElement.offsetWidth
and HTMLElement.offsetHeight
properties. Most of the time these are the same as width and height of Element.getBoundingClientRect()
, when there aren't any transforms applied to the element. In case of transforms, the offsetWidth
and offsetHeight
returns the element's layout width and height, while getBoundingClientRect()
returns the rendering width and height. As an example, if the element has width: 100px;
and transform: scale(0.5);
the getBoundingClientRect()
will return 50 as the width, while offsetWidth
will return 100.Tailwind CSS works by scanning all of your HTML files, JavaScript components, and any other templates for class names, generating the corresponding styles and then writing them to a static CSS file.
It’s fast, flexible, and reliable — with zero-runtime.
Pre tento produkt nie je možné pridávať recenzie.
Free shipping for order above $150
Within 30 days for an exchange
24 hours a day, 7 days a week