Skip to content

Instantly share code, notes, and snippets.

@cbfrance
Created January 1, 2011 07:20
Show Gist options
  • Save cbfrance/761613 to your computer and use it in GitHub Desktop.
Save cbfrance/761613 to your computer and use it in GitHub Desktop.
viewport rainbows with @media conditions
# #!/usr/bin/ruby
rgb_value = 255
pixel_coordinate = rgb_value * 10
while pixel_coordinate > 0 do
print "@media only screen and (max-width: #{pixel_coordinate}px) { \n body { \n background-color: rgb(#{rgb_value},#{rgb_value},#{rgb_value}); } \n }\n"
(pixel_coordinate / 255) % 2 == 0 ? rgb_value += 1 : rgb_value -= 1
pixel_coordinate -= 1
end
@cbfrance
Copy link
Author

cbfrance commented Jan 1, 2011

This is just a proof of concept to see of multiple (hundreds) of @media queries was efficient enough to generate seamless hue transformations. It is! It's perfectly fast. Theoretically you could use this for javascript-free parallax effects ala http://github.com/404. Which I'm sure you need all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment