Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/percent-string
create '%' appended strings for settings CSS properties
https://github.com/binocarlos/percent-string
Last synced: 11 days ago
JSON representation
create '%' appended strings for settings CSS properties
- Host: GitHub
- URL: https://github.com/binocarlos/percent-string
- Owner: binocarlos
- Created: 2014-07-09T15:19:49.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-07-15T11:42:45.000Z (over 10 years ago)
- Last Synced: 2024-11-03T17:05:48.351Z (17 days ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
percent-string
==============create '%' appended strings for settings CSS properties
## installation
npm:
```
$ npm install percent-string
```component:
```
$ component install binocarlos/percent-string
```## usage
Use this module to convert numbers into percent strings
```js
var percent = require('percent-string')document.querySelector('#thing').style.left = percent(24)
document.querySelector('#thing').style.top = percent('24%')
```## api
#### `var string = percent(value, max)`
returns a string of the form: [num] + '%' regardless of the input type.
The zero value is '0%'
max indicates the scale so you can do 0.4 = 40%
```js
var st = percent(.4, 1)// st = '40%'
```### license
MIT