https://github.com/dy/aligner
Align DOM elements as Photoshop/Illustrator does
https://github.com/dy/aligner
Last synced: about 1 year ago
JSON representation
Align DOM elements as Photoshop/Illustrator does
- Host: GitHub
- URL: https://github.com/dy/aligner
- Owner: dy
- License: unlicense
- Created: 2014-11-13T17:12:41.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-04-14T16:42:10.000Z (about 9 years ago)
- Last Synced: 2025-03-24T08:41:39.687Z (about 1 year ago)
- Language: JavaScript
- Homepage: http://dy.github.io/aligner
- Size: 33.2 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# Aligner
Align DOM elements just like photoshop/illustrator aligner does. [Demo](http://dfcreative.github.io/aligner).
```js
npm install aligner
```
```js
var align = require('aligner');
var els = document.querySelectorAll('div');
//align all elements by the left edge.
align(els, 'left');
```
## API
`align(elements, alignment?, alignTarget?)` - align element according to the params passed.
* `elements` - a set of elements to align
* `alignment` values: `'top'`, `'bottom'`, `'left'`, `'right'`, `'center'` (centered align by x), `'middle'` (centered align by y), a number [0..1] to align by x, or array [xAlign?, yAlign?], where alignment is a number [0..1]. Default is 0 (align left).
* `alignTarget` is an element to perform alignment relative to, by default it’s the first element in elements.
[](https://nodei.co/npm/aligner/)