OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>Tiled and scaled background with 'transform: scale(1, -1)'</title> |
| 3 <style> |
| 4 div { |
| 5 width: 100px; |
| 6 height: 100px; |
| 7 } |
| 8 #subject { |
| 9 background-size: 95px 100px; |
| 10 -webkit-transform: scale(1, -1); |
| 11 transform: scale(1, -1); |
| 12 } |
| 13 </style> |
| 14 <div id=back> |
| 15 <div id=subject></div> |
| 16 </div> |
| 17 <script> |
| 18 function stripedImage(c1, c2) { |
| 19 var c = document.createElement('canvas'); |
| 20 c.width = c.height = 100; |
| 21 var ctx = c.getContext('2d'); |
| 22 ctx.fillStyle = c1; |
| 23 ctx.fillRect(0, 0, 100, 50); |
| 24 ctx.fillStyle = c2; |
| 25 ctx.fillRect(0, 50, 100, 50); |
| 26 return c.toDataURL('image/png'); |
| 27 } |
| 28 document.getElementById('back').style.background = 'url(' + stripedImage('#080',
'#f00') + ')'; |
| 29 document.getElementById('subject').style.backgroundImage = 'url(' + stripedImage
('#080', 'transparent') + ')'; |
| 30 </script> |
OLD | NEW |