Skip to content

Commit

Permalink
format readme code
Browse files Browse the repository at this point in the history
  • Loading branch information
songsiqi committed Jul 9, 2016
1 parent 2ac06c4 commit 20e30fa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ One raw stylesheet: `test.css`

```
.selector {
width: 150px;
height: 64px; /*px*/
font-size: 28px; /*px*/
border: 1px solid #ddd; /*no*/
width: 150px;
height: 64px; /*px*/
font-size: 28px; /*px*/
border: 1px solid #ddd; /*no*/
}
```

Expand All @@ -88,53 +88,53 @@ Rem version: `test.debug.css`

```
.selector {
width: 2rem;
border: 1px solid #ddd;
width: 2rem;
border: 1px solid #ddd;
}
[data-dpr="1"] .selector {
height: 32px;
font-size: 14px;
height: 32px;
font-size: 14px;
}
[data-dpr="2"] .selector {
height: 64px;
font-size: 28px;
height: 64px;
font-size: 28px;
}
[data-dpr="3"] .selector {
height: 96px;
font-size: 42px;
height: 96px;
font-size: 42px;
}
```

@1x version: `test1x.debug.css`

```
.selector {
width: 75px;
height: 32px;
font-size: 14px;
border: 1px solid #ddd;
width: 75px;
height: 32px;
font-size: 14px;
border: 1px solid #ddd;
}
```

@2x version: `test2x.debug.css`

```
.selector {
width: 150px;
height: 64px;
font-size: 28px;
border: 1px solid #ddd;
width: 150px;
height: 64px;
font-size: 28px;
border: 1px solid #ddd;
}
```

@3x version: `test3x.debug.css`

```
.selector {
width: 225px;
height: 96px;
font-size: 42px;
border: 1px solid #ddd;
width: 225px;
height: 96px;
font-size: 42px;
border: 1px solid #ddd;
}
```

Expand Down
2 changes: 1 addition & 1 deletion lib/px2rem.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Px2rem.prototype.generateRem = function (cssText) {
var declaration = declarations[j];
// need transform: declaration && has 'px'
if (declaration.type === 'declaration' && pxRegExp.test(declaration.value)) {
var nextDeclaration = rule.declarations[j + 1];
var nextDeclaration = declarations[j + 1];
if (nextDeclaration && nextDeclaration.type === 'comment') { // next next declaration is comment
if (nextDeclaration.comment.trim() === config.forcePxComment) { // force px
// do not transform `0px`
Expand Down
2 changes: 2 additions & 0 deletions test/px2rem.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var assert = require('assert');
var Px2rem = require('../lib/px2rem');
var path = require('path');
Expand Down

0 comments on commit 20e30fa

Please sign in to comment.