{"id":973,"date":"2014-09-26T21:22:26","date_gmt":"2014-09-26T19:22:26","guid":{"rendered":"http:\/\/hesmid.nl\/test\/?p=973"},"modified":"2016-01-20T13:01:04","modified_gmt":"2016-01-20T12:01:04","slug":"retina-sprites","status":"publish","type":"post","link":"https:\/\/hesmid.nl\/test\/retina-sprites\/","title":{"rendered":"Retina Sprites"},"content":{"rendered":"<p><strong>Updated June 3 2015<\/strong><\/p>\n<p>1. Make sure you have all png images in both the normal and the retina version.<\/p>\n<p>2. Make sure the retina versions are exactly 2x bigger than the normal versions<\/p>\n<p><del>3. Create 2 zip files. 1 for the normal images and 1 for the retina versions<\/del><\/p>\n<p>4. Got to\u00a0<a href=\"http:\/\/spritegen.website-performance.org\/\">http:\/\/spritegen.website-performance.org\/<\/a><\/p>\n<p>5. <del>Upload the normal zip file. Choose offset of 25px.\u00a0Copy the css and download the file<\/del><br \/>\n<del> Update: because of some Safari bug it may be better to use 50px for the normal and 100px for the @2x sprite<\/del><\/p>\n<p>Drag the images to the generator. Choose padding of 5px. Choose a vertical layout. Click downloads and save the sprite and the stylesheet.<\/p>\n<p>6. <del>Upload the retina zip file. Choose offset of 50px.<\/del>\u00a0Do the same for the retina images, but choose a padding of 10px. Copy the css and download the file<\/p>\n<p><strong>Note 1:<\/strong><!--more--><\/p>\n<p><a href=\"http:\/\/creativebits.org\/webdev\/safari_background_repeat_bug_fix\">Safari has a problem with repeating background images<\/a>. Fortunately this can be easily solved by specifying a large enough horizontal offset value (configurable).<\/p>\n<p><strong>Note 2:<\/strong><strong><br \/>\n<\/strong>If the @2x sprite is larger than 2000px the generator creates a new column, <span style=\"text-decoration: underline;\">which we do not want<\/span>.<\/p>\n<p>From the website: &#8220;Opera 9.0 and below have a bug which affects CSS background offsets less than -2042px. All values less than this are treated as -2042px exactly. With this option is selected CSS Sprite Generator creates a new column each time the vertical offset reaches -2000px.&#8221;<\/p>\n<p>So it is best to uncheck the option &#8216;wrap columns for Opera bug&#8217; (who uses Opera anyway? Let alone &lt; 9.0).<\/p>\n<p>7. You may want to optimize the downloaded sprites.<\/p>\n<p>8. Add the css rules to _sprites.less (or something).<\/p>\n<p>9. Change the stitches rule:<\/p>\n<pre lang=\"css\">.stitches-sprite(@x: 0, @y: 0, @width: '', @height: '') {\r\n  background-position: @x @y;\r\n  width: @width;\r\n  height: @height;\r\n}\r\n<\/pre>\n<p>Also add an extra rule:<\/p>\n<pre lang=\"css\">.sprite-backgroundsize(@img-w, @new-w, @sprite-width, @sprite-height){\r\n background-size: (@new-w\/@img-w)*@sprite-width (@new-w\/@img-w)*@sprite-height;\r\n}<\/pre>\n<p>And this rule<\/p>\n<pre lang=\"css\">.sprite-2x {\r\n  background-image: url(..\/img\/spritesheet_2x.png);\r\n  background-repeat: no-repeat;\r\n  display: block;\r\n}\r\n<\/pre>\n<p>And remove the background sizes form the icon rules:<br \/>\nSo this:<\/p>\n<pre lang=\"css\">.sprite-icon-1 {\r\n  .stitches-sprite(-5px, -175px, 24px, 24px);\r\n}\r\n<\/pre>\n<p>becomes:<\/p>\n<pre lang=\"css\">.sprite-icon-1 {\r\n  .stitches-sprite(-5px, -175px);\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>10. Now you can add a background image like this:<\/p>\n<p>General rule:<\/p>\n<pre lang=\"css\">.icon {\r\n  .sprite();\r\n  @media\r\n  (-webkit-min-device-pixel-ratio: 2),\r\n  (min-resolution: 192dpi) {\r\n    .sprite-2x();\r\n  }\r\n  background-size: \/\/USE SIZE OF SPRITE HERE!\r\n  height: 24px;\r\n  width: 24px;\r\n}\r\n<\/pre>\n<p>Specific icon:<\/p>\n<pre lang=\"css\">icon-1 {\r\n  .sprite-icon-1()\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Done. If you ever need to change or add images to the sprites, you will only need to change the css rules in _sprites.less<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updated June 3 2015 1. Make sure you have all png images in both the normal and the retina version. 2. Make sure the retina versions are exactly 2x bigger than the normal versions 3. Create 2 zip files. 1 for the normal images and 1 for the retina versions 4. Got to\u00a0http:\/\/spritegen.website-performance.org\/ 5. Upload [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[20],"tags":[47,77,78],"acf":[],"_links":{"self":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/973"}],"collection":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/comments?post=973"}],"version-history":[{"count":12,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/973\/revisions"}],"predecessor-version":[{"id":1413,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/posts\/973\/revisions\/1413"}],"wp:attachment":[{"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/media?parent=973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/categories?post=973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hesmid.nl\/test\/wp-json\/wp\/v2\/tags?post=973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}