Skip to content

Commit

Permalink
Update examples to not combine density and width (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <[email protected]>
  • Loading branch information
nfriedly and sindresorhus authored May 6, 2021
1 parent 2c153e4 commit e3f8b25
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ $ npm install srcset
How an image with `srcset` might look like:

```html
<img alt="The Breakfast Combo"
src="banner.jpg"
srcset="banner-HD.jpg 2x, banner-phone.jpg 100w, banner-phone-HD.jpg 100w 2x">
<img
alt="The Breakfast Combo"
src="banner.jpg"
srcset="banner-HD.jpg 2x, banner-phone.jpg 100w"
>
```

Then have some fun with it:
Expand All @@ -41,15 +43,14 @@ console.log(parsed);
*/

parsed.push({
url: 'banner-phone-HD.jpg',
width: 100,
density: 2
url: 'banner-super-HD.jpg',
density: 3
});

const stringified = srcset.stringify(parsed);
console.log(stringified);
/*
banner-HD.jpg 2x, banner-phone.jpg 100w, banner-phone-HD.jpg 100w 2x
banner-HD.jpg 2x, banner-phone.jpg 100w, banner-super-HD.jpg 3x
*/
```

Expand Down

0 comments on commit e3f8b25

Please sign in to comment.