https://github.com/desandro/get-size
:triangular_ruler: Measure elements
https://github.com/desandro/get-size
Last synced: 11 months ago
JSON representation
:triangular_ruler: Measure elements
- Host: GitHub
- URL: https://github.com/desandro/get-size
- Owner: desandro
- License: mit
- Created: 2012-12-20T01:16:40.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2021-12-29T14:35:20.000Z (about 4 years ago)
- Last Synced: 2024-10-12T19:47:10.092Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 88.9 KB
- Stars: 174
- Watchers: 8
- Forks: 32
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-web-dev-resources - get-size
README
# getSize
Get the size of elements. Used in [Masonry](https://masonry.desandro.com), [Isotope](https://isotope.metafizzy.co), & [Flickity](https://flickity.metafizzy.co).
``` js
var size = getSize( elem );
// elem can be an element
var size = getSize( document.querySelector('.selector') )
// elem can be a selector string
var size = getSize('.selector')
```
Returns an object with:
+ width, height
+ innerWidth, innerHeight
+ outerWidth, outerHeight
+ paddingLeft, paddingTop, paddingRight, paddingBottom
+ marginLeft, marginTop, marginRight, marginBottom
+ borderLeftWidth, borderTopWidth, borderRightWidth, borderBottomWidth
+ isBorderBox
Browser support: Chrome 51+, Firefox 50+, Edge 12+, Safari 10+,
## Install
npm: `npm install get-size`
Yarn: `yarn add get-size`
## MIT License
getSize is released under the MIT License. Have at it.